TofConverter Class Reference

#include <TofConverter.h>

List of all members.

Public Member Functions

StatusCode convert (const BufferHolder &src, TofDigiCol *des, LumiDigiCol *des2=0)
StatusCode convert (const BufferHolder &tof, const BufferHolder &etf, TofDigiCol *des, LumiDigiCol *des2=0)
StatusCode convert (TofDigiCol *src, WriteRawEvent *&des)

Static Public Member Functions

static TofConverterinstance ()
static void destroy ()

Private Member Functions

 TofConverter ()
 ~TofConverter ()
void unPackETF (uint32_t reDigi, uint32_t &TEId, uint32_t &TEData, uint32_t &TEOverflow, uint32_t &TETorQ)

Private Attributes

TofBuilder m_builder

Static Private Attributes

static TofConverters_instance = 0


Detailed Description

Definition at line 10 of file TofConverter.h.


Constructor & Destructor Documentation

TofConverter::TofConverter (  )  [private]

Definition at line 154 of file TofConverter.cxx.

Referenced by instance().

00155 {
00156 }

TofConverter::~TofConverter (  )  [private]

Definition at line 158 of file TofConverter.cxx.

00159 {
00160 }


Member Function Documentation

StatusCode TofConverter::convert ( TofDigiCol src,
WriteRawEvent *&  des 
)

Definition at line 149 of file TofConverter.cxx.

References m_builder, and TofBuilder::pack().

00150 {
00151    return m_builder.pack(src, des);
00152 }

StatusCode TofConverter::convert ( const BufferHolder tof,
const BufferHolder etf,
TofDigiCol des,
LumiDigiCol des2 = 0 
)

Definition at line 29 of file TofConverter.cxx.

References BufferHolder::bufSize(), count, deljobs::end, TofBuilder::getTEID(), genRecEmupikp::i, if(), ganga-rec::j, m_builder, BufferHolder::nBuf(), genRecEmupikp::range, EvtCyclic3::second(), EVENT::tofDigi, TofBuilder::unPack(), and unPackETF().

00033 {
00034    uint32_t REId, TEId, TEData, TEOverflow, TETorQ;
00035    uint32_t n1buf = tof.nBuf();
00036    uint32_t n2buf = etf.nBuf();
00037    uint32_t nbuf = n1buf + n2buf;
00038 
00039    TofDigi* tofDigi;
00040    typedef std::multimap<uint32_t, TofDigi*>::iterator my_iter;
00041    std::multimap<uint32_t, TofDigi*> mapIdData;
00042    my_iter it;
00043 
00044    for (uint32_t i = 0; i < nbuf; ++i) {
00045       bool isTof = (i < n1buf);
00046       const BufferHolder& rBH = isTof ? tof : etf;
00047       uint32_t ii = isTof ? i : (i-n1buf);
00048       uint32_t* buf = rBH(ii);
00049       uint32_t  bufSize = rBH.bufSize(ii);
00050       for (uint32_t j = 0; j < bufSize; ++j) {
00051          if ( isTof ) {
00052              m_builder.unPack(buf[j], REId, TEData, TEOverflow, TETorQ);
00053              TEId = m_builder.getTEID( REId);
00054          }
00055          else { //ETF
00056              this->unPackETF(buf[j], TEId, TEData, TEOverflow, TETorQ);
00057          }
00058 
00059          if ( TEId == 0xFFFFFFFF ) {
00060             uint32_t data_unit = buf[j];
00061             if ( (data_unit >> 25) == 0x7F ) {
00062                tofDigi = new TofDigi(Identifier(0xFFFFFFFF), 0x7FFFFFFF, 0x7FFFFFFF);
00063                tofDigi->setOverflow(data_unit);
00064                des->push_back(tofDigi);
00065             }
00066             continue;
00067          }
00068 
00069          uint32_t count = mapIdData.count(TEId);
00070 
00071          if (count == 0) {
00072             if (TETorQ) {  //Q
00073                tofDigi = new TofDigi(Identifier(TEId), 0x7FFFFFFF, TEData);
00074                tofDigi->setOverflow(0x10 | (TEOverflow<<1));
00075             }
00076             else {  //T
00077                tofDigi = new TofDigi(Identifier(TEId), TEData, 0x7FFFFFFF);
00078                tofDigi->setOverflow(0x20 | TEOverflow);
00079             }
00080             mapIdData.insert(make_pair(TEId, tofDigi));
00081          }
00082          else {
00083             pair<my_iter, my_iter> range = mapIdData.equal_range(TEId);
00084             it = range.first;
00085             tofDigi = it->second;
00086             if (TETorQ) {  //Q
00087                if (tofDigi->getChargeChannel() == 0x7FFFFFFF) {  //matched Q and T, first Q
00088                   tofDigi->setChargeChannel(TEData);
00089                   tofDigi->setOverflow((tofDigi->getOverflow() | (TEOverflow<<1)) & 0xF);
00090                   while ((++it) != range.second) {  //multiT
00091                      tofDigi = it->second;
00092                      tofDigi->setOverflow(tofDigi->getOverflow() & 0xF);
00093                   }
00094                }
00095                else {  //multiQ
00096                   uint32_t flag = (tofDigi->getOverflow() & 0x3C) | 8;
00097                   while (it != range.second) {
00098                      tofDigi = (it++)->second;
00099                      tofDigi->setOverflow((tofDigi->getOverflow()&0x3) | flag);
00100                   }
00101                   tofDigi = new TofDigi(Identifier(TEId), 0x7FFFFFFF, TEData);
00102                   tofDigi->setOverflow(flag | (TEOverflow<<1));
00103                   mapIdData.insert(make_pair(TEId, tofDigi));
00104                }
00105             }
00106             else {  //T
00107                if (tofDigi->getTimeChannel() == 0x7FFFFFFF) {  //matched T and Q, firstT
00108                   tofDigi->setTimeChannel(TEData);
00109                   tofDigi->setOverflow((tofDigi->getOverflow() | TEOverflow) & 0xF);
00110                   while ((++it) != range.second) {  //multiQ
00111                      tofDigi = it->second;
00112                      tofDigi->setOverflow(tofDigi->getOverflow() & 0xF);
00113                   }
00114                }
00115                else {  //multiT
00116                   uint32_t flag = (tofDigi->getOverflow() & 0x3C) | 4;
00117                   while (it != range.second) {
00118                      tofDigi = (it++)->second;
00119                      tofDigi->setOverflow((tofDigi->getOverflow()&0x3) | flag);
00120                   }
00121                   tofDigi = new TofDigi(Identifier(TEId), TEData, 0x7FFFFFFF);
00122                   tofDigi->setOverflow(flag | TEOverflow);
00123                   mapIdData.insert(make_pair(TEId, tofDigi));
00124                }
00125             }
00126          }
00127       }
00128    }
00129 
00130    my_iter end = mapIdData.end();
00131    for (it = mapIdData.begin(); it != end; ++it) {
00132       TEId = it->first;
00133       tofDigi = it->second;
00134       if ( (TEId&0xFFFF7FFF) != 0x20000060 ) {
00135          des->push_back(tofDigi);
00136       }
00137       //zoujh: for luminosity
00138       else {
00139          if (des2 != 0) {
00140             des2->push_back(new LumiDigi(tofDigi));
00141          }
00142          delete tofDigi;
00143       }
00144    }
00145 
00146    return StatusCode::SUCCESS;
00147 }

StatusCode TofConverter::convert ( const BufferHolder src,
TofDigiCol des,
LumiDigiCol des2 = 0 
)

Definition at line 23 of file TofConverter.cxx.

Referenced by RawDataTofDigiCnv::createObj(), RawDataTofDigiCnv::createRep(), MixerAlg::decodeTof(), and RawEventReader::execute().

00024 {
00025     BufferHolder tmp;
00026     return this->convert(src, tmp, des, des2);
00027 }

void TofConverter::destroy (  )  [static]

Definition at line 15 of file TofConverter.cxx.

References s_instance.

Referenced by RawDataTofDigiCnv::~RawDataTofDigiCnv(), and RawEventReader::~RawEventReader().

00016 {
00017    if ( s_instance != 0 ) {
00018       delete s_instance;
00019       s_instance = 0;
00020    }
00021 }

TofConverter * TofConverter::instance (  )  [static]

Definition at line 6 of file TofConverter.cxx.

References s_instance, and TofConverter().

Referenced by RawDataTofDigiCnv::initialize(), MixerAlg::MixerAlg(), and RawEventReader::RawEventReader().

00007 {
00008    if ( s_instance == 0 ) {
00009       s_instance = new TofConverter();
00010    }
00011 
00012    return s_instance;
00013 }

void TofConverter::unPackETF ( uint32_t  reDigi,
uint32_t &  TEId,
uint32_t &  TEData,
uint32_t &  TEOverflow,
uint32_t &  TETorQ 
) [private]

Definition at line 162 of file TofConverter.cxx.

References TofID::getIntID().

Referenced by convert().

00164 {
00165     if ( (reDigi>>25) == 0x7F ) { //Error data!
00166         TEId = 0xFFFFFFFF;
00167         return;
00168     }
00169     int ew = reDigi>>31;
00170     int id = ((reDigi>>25)&0x3F);
00171     int pad = ((reDigi>>21)&0xF);
00172     int sb = ((reDigi>>20)&1);
00173 
00174     TEId = TofID::getIntID(3/*barrel_ec, 3 means ETF*/, ew, id, pad, sb);
00175     TEData = reDigi&0x7FFFF;
00176     TEOverflow = 0;
00177     TETorQ = ((reDigi>>19)&1);
00178 }


Member Data Documentation

TofBuilder TofConverter::m_builder [private]

Definition at line 39 of file TofConverter.h.

Referenced by convert().

TofConverter * TofConverter::s_instance = 0 [static, private]

Definition at line 42 of file TofConverter.h.

Referenced by destroy(), and instance().


Generated on Tue Nov 29 23:36:04 2016 for BOSS_7.0.2 by  doxygen 1.4.7