BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
////////////////////////////////////////////////////////////////
//                                                            //
// BrRawDataOutput provides an interface to generate raw data //
// format starting with digitized data                        //
//                                                            //
// The class is derived from the general input/output class   //
// and falls natural into the hierachi of module classes.     //
//                                                            //
////////////////////////////////////////////////////////////////

//  $Id: BrRawDataOutput.cxx,v 1.2 2001/06/22 17:40:44 cholm Exp $
//
#include <iostream.h>

#include "BrRawDataOutput.h"
#ifndef BRAT_BrRawDataInput
#include "BrRawDataInput.h"
#endif
#ifndef BRAT_BrDataTable
#include "BrDataTable.h"
#endif
#ifndef BRAT_BrEvent
#include "BrEvent.h"
#endif
#ifndef BRAT_BrEventIO
# include "BrEventIO.h"
#endif
#ifndef ROOT_TSystem
#include "TSystem.h"
#endif



// Following included only to get error definitions; use interface
// object instead 
#ifndef BrRawIOH
#include "BrRawIO.h"
#endif

// Following included only to get error definitions; use interface
// object instead 
#ifndef NODISPATCH
#ifndef DisIOH
#include "DisIO.h"
#endif
#endif

//Include files for different detector components
#ifndef BRAT_BrZdcDig
#include "BrZdcDig.h"
#endif
#ifndef BRAT_BrBbDig
#include "BrBbDig.h"
#endif
#ifndef BRAT_BrTileDig
#include "BrTileDig.h"
#endif
#ifndef BRAT_BrSiDig
#include "BrSiDig.h"
#endif
#ifndef BRAT_BrTofDig
#include "BrTofDig.h"
#endif
#ifndef BRAT_BrC1Dig
#include "BrC1Dig.h"
#endif

ClassImp(BrRawDataOutput);

//___________________________________________________________________
 BrRawDataOutput::BrRawDataOutput()
{
  //
  //  Constructor. Set fFilePointer and fEventCounter to NULL
  //  In root environment use the named constructor normally.
#ifdef _BRDEBUG
  cout << "Ctor : BrRawDataOutput " << endl;
#endif

  fFileDescriptor  = NULL;
#ifndef NODISPATCH
  fDispatcher      = NULL;
#endif
  fRawEvent        = NULL;
  fReadMode        = kNULLMode;
}
//____________________________________________________________________
 BrRawDataOutput::BrRawDataOutput(Char_t *Name) :
  BrIOModule(Name, Name)
{
  //
  // Constructor. Set fFilePointer and fEventCounter to NULL
  // name becomes Name and Title for the Module.
  // No data file is opened this has to be done in
  // the Open() method.
  //
  fFileDescriptor  = NULL;
#ifndef NODISPATCH
  fDispatcher      = NULL;
#endif
  fRawEvent        = NULL;
  fReadMode        = kNULLMode;
  Init();
}
//_____________________________________________________________________
 BrRawDataOutput::~BrRawDataOutput(){
  //
  //  Destructor for BrRawDataOutput. Close the file if open.
  //
  if(fRawEvent) delete fRawEvent; fRawEvent = 0;
  if(fFileDescriptor) delete fFileDescriptor; fFileDescriptor = 0;
#ifndef NODISPATCH
  if(fDispatcher)     delete fDispatcher;     fDispatcher = 0;
#endif
}

//______________________________________________________________________
 void BrRawDataOutput::Init() {
  // Initialize variables
  //Set the default value of unpack everything

  fReqBatch = 50;                //Default value
  fBatchNumber = fReqBatch + 1;  //Needs to be larger for first pass
  SetAllOn();
  ZeroNodesAndTables();
}

//_________________________________________________________________
 Bool_t BrRawDataOutput::Open(const Char_t *fname, const Option_t *option)
{
  // Open the input digitized file with fname".root"
  // Open the output raw data file with fname.lmd
  Char_t filenameInt[256];

  fIOStatus = 0;

  //Save the file name for posterity
  strcpy(fFileName,fname);
  //Find the last .root if specified
  Char_t *dotroot = strstr(fFileName,".root");    
  //Find the last .lmd if specified
  Char_t *dotlmd  = strstr(fFileName,".lmd");     

  //Construct a .root file from whatever input file we give.
  //Rules:
  //if filename.root                  use same filename
  //if filename.lmd                   construct filename.root
  //if filename                       construct filename.root
  //if filename.something.something   construct
  //                                  filename.something.something.root
  if(dotroot) {
    strcpy(filenameInt,fFileName);
  }
  else if(dotlmd) {
    strcpy(filenameInt,fFileName);
    // put .root over .lmd
    Char_t *dot = strstr(filenameInt,".lmd");
    strcpy(dot,".root");
  }
  else {
    strcpy(&filenameInt[strlen(fFileName)],".root");
  }

  // First open the digitized input file
  fDigitizedEventIO = new BrEventIO("Digitized Data");
  Bool_t root_file_status = fDigitizedEventIO->Open(filenameInt,"READ");
  if(!root_file_status) return kFALSE;

  if(!fname) {
    printf("Can't open file : %sn", fname);
    return kFALSE;
  }


  // Construct a .lmd file from whatever input file we give.
  // Rules:
  // if filename.lmd                   use same filename
  // if filename.root                  construct filename.lmd
  // if filename                       construct filename.lmd
  // if filename.something.something   construct
  //                                   filename.something.something.lmd 
  if(dotlmd) {
    strcpy(filenameInt,fFileName);
  }
  else if(dotroot) {
    strcpy(filenameInt,fFileName);
    // put .root over .lmd
    Char_t *dot = strstr(filenameInt,".root");
    strcpy(dot,".lmd");
  }
  else {
    strcpy(&filenameInt[strlen(fFileName)],".lmd");
  }

  fFileDescriptor = new BrRawIOProxy();  //create the BrRawIO interface class
  fFileDescriptor->create();             //create BrRawIO inside there

  //Open the file for writing
  Int_t err = fFileDescriptor->writeopen(filenameInt);
  if(err != BrRawIO::kOk) {
    printf("Can't open File %sn",filenameInt);
    fError = kTRUE;
    if(fRawEvent) {
      delete fRawEvent;
      fRawEvent = NULL;
    }
    return kFALSE;
  }
  else {
    fIOStatus  = 1;
    fNumBytesRead =0;
    fNumBytesWritten =0;
    fRawEvent = new BrRawEvent(); //create the event structure and give it 
    //what it needs.
    return kTRUE;
  }
}

//____________________________________________________________________
 Bool_t BrRawDataOutput::Close()
{
  // Close the file Opened by the object. Return 
  // kFALSE if no file was open.

  if(fFileDescriptor){
    fFileDescriptor->close();
    delete fFileDescriptor;
    fFileDescriptor = NULL;
    delete fRawEvent; fRawEvent = NULL;
  }
  if(fDigitizedEventIO) fDigitizedEventIO->Close();

  return kTRUE;
}

//____________________________________________________________________
 void BrRawDataOutput::SkipEvent(Int_t numevt)
{
  // Skip numevent events in the input file.  This is done by simply
  // doing a read over the 
  // number of events specified.
  // Check if End of file found before
  if(fEof) return;
  fDigitizedEventIO->SkipEvent(numevt);
}

//____________________________________________________________________
 void BrRawDataOutput::Event(BrEvent* event)
{
  // Reads one event from the digitized data file and generate the
  // BrRawEvent Finally, write the BrRawEvent

  BrEvent *digitized_event = new BrEvent("Digitized Event",0,0);
  fDigitizedEventIO->Event(digitized_event);
  
  // Now digitized event has been read into memory.  Now
  // we pack it into BrRawEvent
  
  // First, zero nodes so we can decide if we need to build a new node
  // or not ZeroNodesAndTables();
  
  BuildRawEvent(digitized_event);

  // Write the raw event
  fFileDescriptor->write(*fRawEvent);
}

//____________________________________________________________________
 void BrRawDataOutput::ZeroNodesAndTables() {
  // Zero all nodes and table pointers.

  // Nodes
  fFSNode       = 0;
  fFFSNode      = 0;
  fBFSNode      = 0;
  fMRSNode      = 0;
  fGlobalNode   = 0;

  //Tables
  fZDCTable       = 0;
  fBBLeftTable    = 0;
  fBBRightTable   = 0;
  fH1Table        = 0;
  fH2Table        = 0;
  fC1Table        = 0;
  fMultTilesTable = 0;
  fMultSiTable    = 0;
}

//____________________________________________________________________
 void BrRawDataOutput::BuildRawEvent(BrEvent *event) {
  
  BrRawEvent::RecordHeader *recordlist = 0;
  Int_t numrecords = 0;
  fRawEvent->getRecordList(&numrecords,&recordlist);
  for(Int_t irec=0;irec<numrecords;irec++) {
    Int_t recordId = recordlist[irec].recordId;
    fRecordFormat = fRawEvent->getRecordFormat(recordlist[irec]);
    // printf("recordId = %d, Form = %dn",recordId,fRecordFormat);
    
    if(recordId == BrRawDataInput::kEventHeader) {
      BuildEventHeader(recordId,event);
    }
    else {
      if(fAllOn) {
	Int_t specId   = recordId/1000;
	if(specId == kGlobal) {
	  if(fGlobalOn) DecodeGlobal(recordId,event);
	}
	else if(specId == kMRS) {
	  if(fMRSOn) DecodeMRS(recordId,event);
	}
	else if(specId == kFS) {
	  if(fFSOn) DecodeFS(recordId,event);
	}
	else if(specId < 10) {
	  //          Means unmapped data
	  //          cout<<"specId < 10; it is "<<specId<<"recordId =
	  //          "<<recordId<<endl; 
	}
      }
    }
  }
}

//____________________________________________________________________
 void BrRawDataOutput::BuildEventHeader(const Int_t recordId,
				       BrEvent *event) {
  //Routine to transfer raw event header to BrEventHeader from event
  BrRawEvent::EventHeader *evh_raw;
  Int_t evh_size;
  BrEventHeader *evh = event->GetEventHeader();
  BrRawEvent::Status err = fRawEvent->getEventHeader(evh_raw,evh_size);
  if(err == BrRawEvent::kOk) {
    evh->SetRunNumber(evh_raw->fRunNo);
    evh->SetEventNumber(evh_raw->fEventNo);
    evh->SetTriggerMask(evh_raw->fTrigger);
    evh->SetTime(evh_raw->fEventEvbTime);
    evh->SetEventType(evh_raw->fEventType);
  }
  else {
    cout<<"Warning: Error in event header!!!"<<endl;
  }
}

//____________________________________________________________________
 void BrRawDataOutput::DecodeFS(const Int_t recordId,BrEvent *event) {
  if(!fFSNode) {
    fFSNode = new BrEventNode("FS");
    event->AddEventNode(fFSNode);
  }
  if(fFFSOn) DecodeFFS(recordId);
  if(fBFSOn) DecodeBFS(recordId);
}

//____________________________________________________________________
 void BrRawDataOutput::DecodeFFS(const Int_t recordId) {
  Int_t nhits;
  //BrRawEvent::mappedAdcBlkHit_t *mapped_adc_blk_hits;
  BrRawEvent::mappedATBlkHit_t  *mapped_at_blk_hits;
  //BrRawEvent::mappedAdcTdcHit_t *mapped_adc_tdc_hits;
  Int_t ret;
  Int_t ihit;
  //T1       (tpc)
  //T2       (tpc)
  //WF1       280  TDC L1879      -   x    TDC       121xx
  //WF2       280  TDC L1879      -   x    TDC       122xx
  //H1         80  ADC L1885F     x   x    ADC+TDC   12612
  //Make the new global node if we need to.
  if(!fFFSNode) {
    fFFSNode = new BrEventNode("FFS");
    fFSNode->AddEventNode(fFFSNode);
  }

  switch(recordId) {
  case BrRawDataInput::kH1:
    //   Get H1
    if(fH1On) {
      ret = fRawEvent->getRecordMappedATBlk(BrRawDataInput::kH1,
					    mapped_at_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	//         Do we have to make this check?Will we com here only
	//         once per event?? 
	if(!fH1Table) {
	  fH1Table = new BrDataTable("DigTof TOF1");
	  fFFSNode->AddDataTable(fH1Table);
	}
	if(nhits != 80) {
	  cout<<"nhit for H1 != 80, check it out; it is "<<nhits<<endl;
	}
	for(ihit=0;ihit<40;ihit++) {
	  BrTofDig *digtof_p = new BrTofDig();
	  fH1Table->Add(digtof_p);
	  BrRawEvent::mappedATBlkHit_t *hit_up,*hit_down;
	  hit_up   = &mapped_at_blk_hits[ihit];
	  hit_down = &mapped_at_blk_hits[ihit+40];
	  digtof_p->SetSlatno(ihit+1);
	  digtof_p->SetAdcDown(hit_down->adc);
	  digtof_p->SetAdcUp(hit_up->adc);
	  digtof_p->SetTdcDown(hit_down->tdc);
	  digtof_p->SetTdcUp(hit_up->tdc);
	}
      }
      else {
	cout<<"Error on H1"<<endl;
      }
    }
    break;


  case BrRawDataInput::kC1:
    if(fC1On) {
      //       First check that the record format is what we will
      //       read.  If not iform user and get out as what we would
      //       do would be bogus anyway 
      if(fRecordFormat != BrRawEvent::kFormatATBlk) {
	cout<<"Record format for C1 not correct; it is ";
	cout<<fRecordFormat;
	cout<<endl;
	return;
      }
      ret=fRawEvent->getRecordMappedATBlk(BrRawDataInput::kC1,mapped_at_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	BrC1Dig *digc1_p;
	//          Check if C1 table was already created.  If not,
	//          make it, and add to node.  Then create BrC1Dig and
	//          add to table.  If it was already created, give an
	//          error message 
	if(!fC1Table) {
	  fC1Table = new BrDataTable("BrC1Dig");
	  fFFSNode->AddDataTable(fC1Table);

	  digc1_p = new BrC1Dig();
	  fC1Table->Add(digc1_p);

	}
	else {
	  cout<<"C1 table already created; how did that happen; "
	      << "check it out"<<endl;
	}


	if(nhits != 32) {
	  cout<<"C1:nhits !=32, they are "<<nhits<<" returning!!!";
	  cout<<endl;
	  return;
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrRawEvent::mappedATBlkHit_t *hit = &mapped_at_blk_hits[ihit];

	  digc1_p->SetAdc(ihit,hit->adc);
 
	}
      }
      else {
	cout<<"Error on C1"<<endl;
      }
    }
    break;


  default:
    break;
  }

  //Get T1
  //Get T2
  //Get WF1
  //Get WF2
  //Get H1
  //Get C1
}

//____________________________________________________________________
 void BrRawDataOutput::DecodeBFS(const Int_t recordId) {
  Int_t nhits;
  //BrRawEvent::mappedAdcTdcHit_t *mapped_adc_tdc_hits;
  //BrRawEvent::mappedAdcBlkHit_t *mapped_adc_blk_hits;
  BrRawEvent::mappedATBlkHit_t *mapped_at_blk_hits;
  Int_t ret;
  Int_t ihit;
  //H2         64  ADC L1885F     x   x    ADC+TDC   12613
  //               TDC P7186
  //C1         32  ADC L1885F     x   ?    ADC+TDC   12614
  //T3      (D.C.) TDC L1877S     -   x    TDC       123xx
  //T4      (D.C.) TDC L1877S     -   x    TDC       124xx
  //T5      (D.C.) TDC L1877S     -   x    TDC       125xx
  //RICH      320  ADC L1885F     x   ?    ADCBLK    12615
  if(!fBFSNode) {
    fBFSNode = new BrEventNode("BFS");
    fFSNode->AddEventNode(fBFSNode);
  }

  switch(recordId) {
  case BrRawDataInput::kH2:
    //    Get H2
    if(fH2On) {
      printf("Calling getRecordMapped businessn");
      ret = fRawEvent->getRecordMappedATBlk(BrRawDataInput::kH2, 
					    mapped_at_blk_hits,nhits);
      printf("Back from business, nhits = %dn",nhits);
      if(ret == BrRawEvent::kOk) {
	//          Necessary to make this check? Will we come here
	//          only once per event 
	if(!fH2Table) {
	  fH2Table = new BrDataTable("DigTof TOF2");
	  fBFSNode->AddDataTable(fH2Table);
	}
	if(nhits != 80) {
	  cout<<"nhit for H2 != 80, check it out; it is "<<nhits<<endl;
	}
	for(ihit=0;ihit<40;ihit++) {
	  BrTofDig *digtof_p = new BrTofDig();
	  fH2Table->Add(digtof_p);
	  BrRawEvent::mappedATBlkHit_t *hit_up,*hit_down; 
	  hit_up   = &mapped_at_blk_hits[ihit];
	  hit_down = &mapped_at_blk_hits[ihit+40];
	  digtof_p->SetSlatno(ihit+1);
	  digtof_p->SetAdcDown(hit_down->adc);
	  digtof_p->SetAdcUp(hit_up->adc);
	  digtof_p->SetTdcDown(hit_down->tdc);
	  digtof_p->SetTdcUp(hit_up->tdc);
	}
      }
      else {
	cout<<"Error on H2"<<endl;
      }
    }
    break;

  default:
    break;
  }

  //Get T3
  //Get T4
  //Get T5
  //Get H2
  //Get RICH
}

//____________________________________________________________________
 void BrRawDataOutput::DecodeMRS(const Int_t recordId,BrEvent *event) {
  //MTP1     (tpc)
  //MTP2     (tpc)
  //WM1       320  TDC L1879      -   x    TDC       111xx
  //WM2       320  TDC L1879      -   x    TDC       112xx
  //TOFW      240  TDC P7186      x   x    ADC+TDC   113xx
  //               ADC L1885F
  //TOFW-2    240  TDC P7186      x   x    ADC+TDC   114xx
  //               ADC L1885F
  //Get MTP1
  //Get MTP2
  //Get WM1
  //Get WM2
  //Get TOFW
  //Get TOFW-2
}

//____________________________________________________________________
 void BrRawDataOutput::DecodeGlobal(const Int_t recordId,BrEvent *event) {
  //ZDC Left   3-4 ADC L2249      x   ?    ADC+TDC   10010
  //ZDC Right  3-4 ADC L2249      x   ?    ADC+TDC   10011
  //BBC Left   45  ADC L1885F     x   x    ADC+TDC   10012
  //               TDC P7186
  //BBC Right  36  ADC L1885F     x   x    ADC+TDC   10013
  //               TDC P7186
  //MultSI    192  ADC L4300      x   -    ADCBLK    10014
  //MultTiles  40  ADC L1885F     x   ?    ADC+TDC   10015
  Int_t nhits;
  BrRawEvent::mappedATBlkHit_t *mapped_at_blk_hits;
  //BrRawEvent::mappedAdcTdcHit_t *mapped_adc_tdc_hits;
  BrRawEvent::mappedAdcBlkHit_t *mapped_adc_blk_hits;
  Int_t ret;
  Int_t ihit;

  //Make the new global node if we need to.
  if(!fGlobalNode) {
    fGlobalNode = new BrEventNode("Global");
    event->AddEventNode(fGlobalNode);
  }

  switch(recordId) {
  case BrRawDataInput::kZDCLeft:
   
    //    Get ZDC Left
    if(fZDCOn) {
      //       First check that the record format is what we will
      //       read.  If not inform user and get out as what we would
      //       do would be bogus anyway 
      if(fRecordFormat != BrRawEvent::kFormatATBlk) {
	cout<<"Record format for ZDC Left not correct; it is "<<fRecordFormat;
	cout<<endl;
	return;
      }
      ret = fRawEvent->getRecordMappedATBlk(BrRawDataInput::kZDCLeft,
					    mapped_at_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	BrZdcDig *digzdc_p;
       
	//          Check if ZDC table was already created.  If not, make it, and add
	//          to node.  Then create BrZdcDig and add to table.
	//          If it was already created, get the BrZdcDig out so
	//          we can fill the rest of it 
	if(!fZDCTable) {
	  fZDCTable = new BrDataTable("BrZdcDig");
	  fGlobalNode->AddDataTable(fZDCTable);
	  digzdc_p = new BrZdcDig();
	  fZDCTable->Add(digzdc_p);
	}
	else {
	  digzdc_p = (BrZdcDig*)fZDCTable->At(0);
	}
       
	if(nhits != 4) {
	  cout<<"ZDC Right:nhits !=4, they are "<<nhits<<" returning!!!";
	  cout<<endl;
	  return;
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrRawEvent::mappedATBlkHit_t *hit = &mapped_at_blk_hits[ihit];
	 
	  if(ihit < 3) {
	    digzdc_p->SetLeftAdc(ihit,hit->adc);
	    digzdc_p->SetLeftTdc(ihit,hit->tdc);
	  }
	  else if(ihit == 3) {
	    digzdc_p->SetLeftAdcSum(hit->adc);
	    digzdc_p->SetLeftTdcSum(hit->tdc);
	  }
	}
      }
      else {
	cout<<"Error on ZDC Left"<<endl;
      }
    }
    break;
   
  case BrRawDataInput::kZDCRight:

    //    Get ZDC Right
    if(fZDCOn) {
      //       First check that the record format is what we will
      //       read.  If not iform user and get out as what we would
      //       do would be bogus anyway 
      if(fRecordFormat != BrRawEvent::kFormatATBlk) {
	cout<<"Record format for ZDC Rightt not correct; it is ";
	cout<<fRecordFormat;
	cout<<endl;
	return;
      }
      ret=fRawEvent->getRecordMappedATBlk(BrRawDataInput::kZDCRight,
					  mapped_at_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	BrZdcDig *digzdc_p;
	//          Check if ZDC table was already created.  If not,
	//          make it, and add to node.  Then create BrZdcDig
	//          and add to table.  If it was already created, get
	//          the BrZdcDig out so we can fill the rest of it 
	if(!fZDCTable) {
	  fZDCTable = new BrDataTable("BrZdcDig");
	  fGlobalNode->AddDataTable(fZDCTable);
	  digzdc_p = new BrZdcDig();
	  fZDCTable->Add(digzdc_p);
	}
	else {
	  digzdc_p = (BrZdcDig*)fZDCTable->At(0);
	}
       
	if(nhits != 4) {
	  cout<<"ZDC Right:nhits !=4, they are "<<nhits<<" returning!!!";
	  cout<<endl;
	  return;
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrRawEvent::mappedATBlkHit_t *hit = &mapped_at_blk_hits[ihit];
	 
	  if(ihit < 3) {
	    digzdc_p->SetRightAdc(ihit,hit->adc);
	    digzdc_p->SetRightTdc(ihit,hit->tdc);
	  }
	  else if(ihit == 3) {
	    digzdc_p->SetRightAdcSum(hit->adc);
	    digzdc_p->SetRightTdcSum(hit->tdc);
	  }
	 
	}
      }
      else {
	cout<<"Error on ZDC Right"<<endl;
      }
    }
    break;
   
  case BrRawDataInput::kBBCLeft:
    //    Get BBC Left
    if(fBBOn) {
      if(fRecordFormat != BrRawEvent::kFormatATBlk) {
	cout<<"Record format for BBC Left not correct; it is ";
	cout<<fRecordFormat;
	cout<<endl;
	return;
      }
      ret = fRawEvent->getRecordMappedATBlk(BrRawDataInput::kBBCLeft,
					    mapped_at_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	//          Does this check need to be made?  Will we come here only once 
	//          per event??
	if(!fBBLeftTable) {
	  fBBLeftTable = new BrDataTable("DigBB Left");
	  fGlobalNode->AddDataTable(fBBLeftTable);
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrBbDig *digbb_p = new BrBbDig();
	  fBBLeftTable->Add(digbb_p);
	  BrRawEvent::mappedATBlkHit_t *hit = &mapped_at_blk_hits[ihit];
	  digbb_p->SetId(ihit+1);     //is this right???
	  digbb_p->SetAdc(hit->adc);
	  digbb_p->SetTubeNo(ihit+1);
	  digbb_p->SetTdc(hit->tdc);
	}
      }
      else {
	cout<<"Error on BBC Left"<<endl;
      }
    }
    break;
   
  case BrRawDataInput::kBBCRight:
    //    Get BBC Right
    if(fBBOn) {
      if(fRecordFormat != BrRawEvent::kFormatATBlk) {
	cout<<"Record format for BBC Rightt not correct; it is ";
	cout<<fRecordFormat;
	cout<<endl;
	return;
      }
      ret =fRawEvent->getRecordMappedATBlk(BrRawDataInput::kBBCRight,
					   mapped_at_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	//          Does this check need to be made?  Will we come here only 
	//          once per event??
	if(!fBBRightTable) {
	  fBBRightTable = new BrDataTable("DigBB Right");
	  fGlobalNode->AddDataTable(fBBRightTable);
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrBbDig *digbb_p = new BrBbDig();
	  fBBRightTable->Add(digbb_p);
	  BrRawEvent::mappedATBlkHit_t *hit = &mapped_at_blk_hits[ihit];
	  digbb_p->SetId(ihit+1);     //is this right???
	  digbb_p->SetAdc(hit->adc);
	  digbb_p->SetTubeNo(ihit+1);
	  digbb_p->SetTdc(hit->tdc);
	}
      }
      else {
	cout<<"Error on BBC Left"<<endl;
      }
    }
    break;
   
  case BrRawDataInput::kMultSi:
    //    Get MultSi
    if(fMultOn) {
      if(fRecordFormat != BrRawEvent::kFormatAdcBlk) {
	cerr<<"Record format for MultSi not correct; it is ";
	cerr<<fRecordFormat;
	cerr<<endl;
	return;
      }
      ret = fRawEvent->getRecordMappedAdcBlk(BrRawDataInput::kMultSi,
					     mapped_adc_blk_hits,nhits);
      if(ret == BrRawEvent::kOk) {
	if(!fMultSiTable) {
	  fMultSiTable = new BrDataTable("MultSi");
	  fGlobalNode->AddDataTable(fMultSiTable);
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrRawEvent::mappedAdcBlkHit_t *hit = &mapped_adc_blk_hits[ihit];
	  BrSiDig *digmultsi_p = new BrSiDig();
	  fMultSiTable->Add(digmultsi_p);
	  digmultsi_p->SetAdc(ihit+1, *hit);
	  //            digmultsi_p->SetTdc(...);
	}
      }
      else {
	cout<<"Error on MultSi"<<endl;
      }
    }
    break;
     
  case BrRawDataInput::kMultTiles:
    //    Get MultTiles
    if(fMultOn) {
      if(fRecordFormat != BrRawEvent::kFormatAdcBlk) {
	cerr<<"Record format for MultTiles not correct; it is ";
	cerr<<fRecordFormat;
	cerr<<endl;
	return;
      }
      ret =
	fRawEvent->getRecordMappedAdcBlk(BrRawDataInput::kMultTiles,
					 mapped_adc_blk_hits,nhits); 
      if(ret == BrRawEvent::kOk) {
	if(!fMultTilesTable) {
	  fMultTilesTable = new BrDataTable("MultTiles");
	  fGlobalNode->AddDataTable(fMultTilesTable);
	}
	for(ihit=0;ihit<nhits;ihit++) {
	  BrRawEvent::mappedAdcBlkHit_t *hit = &mapped_adc_blk_hits[ihit];
	  BrTileDig *digmulttile_p = new BrTileDig();
	  fMultTilesTable->Add(digmulttile_p);
	  digmulttile_p->SetId(ihit+1, ihit+1);
	  digmulttile_p->SetAdc(ihit+1, *hit);
	  //            digmulttile_p->SetTdc(...);
	}
      }
      else {
	cout<<"Error on MultTiles"<<endl;
      }
    }
    break;
   
  default:
    cout<<"Invalid recordId; better check it out, it is "<<recordId<<endl;
    break;
   
  }
 
}




//____________________________________________________________________
//
//  $Log: BrRawDataOutput.cxx,v $
//  Revision 1.2  2001/06/22 17:40:44  cholm
//  Changes t odo with data classes renaming.
//
//  Revision 1.1.1.1  2001/06/21 14:55:09  hagel
//  Initial revision of brat2
//
//  Revision 1.12  2001/01/29 20:37:35  cholm
//  Updated to use the new data objects for the multiplicity array. See the
//  relevant classes (BrTileDig, BrTileRdo, BrSiDig, BrSiRdo) for more details.
//
//  Revision 1.11  2001/01/22 20:00:19  cholm
//  Because renamed BrIOModule::fStatus to BrIOModule::fIOStatus, the classes
//  BrRawDataInput and BrRawDataOutput had to be updated.
//
//  Revision 1.10  2000/11/23 01:35:26  brahmlib
//  Fixed code so that is compiles on Digital Unix
//
//  Revision 1.9  2000/06/28 09:21:57  hagel
//  Added const's to Open Args in BrRawDataInput
//
//  Revision 1.8  2000/06/11 01:25:40  hagel
//  Removed const from Open method args
//
//  Revision 1.7  2000/06/09 18:37:52  hagel
//  Add const to fname in Open; Unknown how that changed
//
//  Revision 1.6  2000/06/03 18:18:53  videbaek
//  Removed methods that belongs to base classes.
//
//  Revision 1.5  2000/05/20 18:18:39  hito
//  I (Hiro) added the Silicon strip detector.
//
//  Revision 1.4  2000/02/15 20:32:27  videbaek
//
//  :q
//  sorry for comments bad term
//  :wq
//
//  Revision 1.3  1999/10/26 16:00:49  videbaek
//  Modified fBytesTransferred to fNumBytesRead and Written to conform to
//  the BrIOModule base class.
//
//  Revision 1.2  1999/10/26 15:35:35  videbaek
//  Fix -maybe temporary for missing constant
//
//  Revision 1.1  1999/10/15 20:27:15  hagel
//  0th version just to put in repository
//
//
// Using namespace alias until we find a good place to put
// all the RawTypes into. The kDetector types are presently defined in
// BrRawDataInput. (fv 2/15/00)
//
// namespace RawType = BrRawDataInput; 
// Had to abandon namespace - did not work with g++
// ok for VC++ 6.0 - is valid C++.

 

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS