next up previous
Next: 4. The emcCalibrator Up: No Title Previous: 2. Where is the

   
3. The emcRawDataAccessor (RDA)

The emcRawDataAccessor is a singleton, which means that only one such object (i.e. one instance of this class) can exist at any time in your program. Here is how you can access this instance :

emcRawDataAccessor* rda = emcRawDataAccessor::GetInstance() ;

This will work only if the RDA has been initialized properly at least once :

int status ;
char* config = ``FEM.conf'' ;
emcRawDataAccessor* rda = emcRawDataAccessor::GetInstance(status, config) ;

The configuration file describes what and where EMCAL FEMs are. Here is how it looks like :

# pos    -> location of the crate within calorimeter Sector (SM144 number)
#           It is used to identify the packet (numbered like 8001+pos)
# pin    -> personal identification number of the Crate (MUST be written on a 
#           sticker on the mother board). Range 0 - 255. Copied into user word
#           in the packet header (module Id) and used to verify the correctness
#           of the Crate-packet relations
# sector -> Sector Identifier
map: emcal
data: towers
fem: pos=0, pin=20, sector=w0
delay: tac=3 post=4
chan: 0-143
fem: pos=1, pin=22, sector=w0
delay: tac=3 post=4
chan: 0-143
...

NOTE: It is good practice to always check that the pointer you get back from the emcRawDataAccessor::GetInstance() method is not null, which would indicate an error.

Once you get a pointer to the RDA, the next step is to obtain a pointer to a RawDataObject :

emcRawDataObject* rdo = rda->GetRawDataObject() ;

NOTE: for performance reasons, the RDO pointer you obtain from the RDA is always the same (unless you re-initialize the RDA in the meantime) so the memory allocation for it is done only once. Its size is fixed by the number of FEMs present in the configuration file (i.e. it is not zero-suppressed).

The actual filling of the RDO is still governed by the RDA (you have no other way of filling it, anyway), by its processEvent(Event*) method. The reader is referred to the ONCS documentation about Event handling for more details about getting access to Event objects[Pur]. A loop over events looks like this :

int status ;
char* config = ``FEM.conf'' ;
emcRawDataAccessor* rda = emcRawDataAccessor::GetInstance(status,config) ;
if (!rda) {
  cerr << ``<E> Cannot get a RDA !'' << endl ;
}
else {
  emcRawDataObject* rdo = rda->GetRawDataObject() ;
  Eventiterator* it = new fileEventiterator(``data.prdf'') ;
  Event* event ;

  while ( event = it->getNextEvent() ) {
    if ( event->getEvtType() == DATAEVENT ) {
      rda->processEvent(event) ;
      // here you can play with the RDO if you need to ...
      cout << (*rdo) << endl ;
    }
  }  
}


next up previous
Next: 4. The emcCalibrator Up: No Title Previous: 2. Where is the
Laurent APHECETCHE - 2000-07-28