MdcConverter Class Reference

#include <MdcConverter.h>

List of all members.

Public Member Functions

void init (int runFrom, int runTo)
void setRunId (int runId)
StatusCode convert (const BufferHolder &src, MdcDigiCol *des)
StatusCode convert (MdcDigiCol *src, WriteRawEvent *&des)

Static Public Member Functions

static MdcConverterinstance (int runMode=2)
static void destroy ()

Private Member Functions

 MdcConverter (int runMode)
 ~MdcConverter ()
 MdcConverter ()

Private Attributes

int m_runMode
int m_runId
int m_runFrom
int m_runTo
uint32_t m_mdcTag [16384][4]
MdcBuilder m_builder

Static Private Attributes

static MdcConverters_instance = 0


Detailed Description

Definition at line 9 of file MdcConverter.h.


Constructor & Destructor Documentation

MdcConverter::MdcConverter ( int  runMode  )  [private]

Definition at line 179 of file MdcConverter.cxx.

00180    : m_runMode( runMode )
00181 {
00182 }

MdcConverter::~MdcConverter (  )  [private]

Definition at line 184 of file MdcConverter.cxx.

00185 {
00186 }

MdcConverter::MdcConverter (  )  [private]

Referenced by instance().


Member Function Documentation

StatusCode MdcConverter::convert ( MdcDigiCol src,
WriteRawEvent *&  des 
)

Definition at line 174 of file MdcConverter.cxx.

References m_builder, and MdcBuilder::pack().

00175 {
00176    return m_builder.pack(src, des);
00177 }

StatusCode MdcConverter::convert ( const BufferHolder src,
MdcDigiCol des 
)

Definition at line 31 of file MdcConverter.cxx.

References BufferHolder::bufSize(), MdcBuilder::getTEID(), genRecEmupikp::i, if(), MdcID::layer(), m_builder, m_mdcTag, m_runFrom, m_runId, m_runMode, m_runTo, EVENT::mdcDigi, BufferHolder::nBuf(), MdcBuilder::unPack(), and MdcID::wire().

Referenced by RawDataMdcDigiCnv::createObj(), RawDataMdcDigiCnv::createRep(), MixerAlg::decodeMdc(), and RawEventReader::execute().

00032 {
00033    //int digiId = 0;
00034    uint32_t TEId, REId, TEData, TEOverflow, TETorQ;
00035 
00036    typedef pair<uint32_t, uint32_t> PairII;
00037    vector<uint32_t>  vHits;
00038    vector<PairII>    vmTDC;
00039 
00040    uint32_t* curTag;
00042 
00043    uint32_t nbuf = src.nBuf();
00044 
00045    for (uint32_t i = 0; i < nbuf; ++i)
00046    {
00047       uint32_t* buf = src(i);
00048       uint32_t* bufend= buf + src.bufSize(i);
00049       for ( ; buf < bufend; ++buf /*, ++digiId*/)
00050       {
00051          uint32_t digi = *buf;
00052          if (((digi>>18) & 0x3FFF) == 0) {
00053             //digiId--;
00054             continue;
00055          }
00056 
00057          m_builder.unPack(digi, REId, TEData, TEOverflow, TETorQ);
00058 
00059          TEId = m_builder.getTEID( REId );
00060          if ( TEId == 0xFFFFFFFF ) continue;
00061 
00062          curTag = m_mdcTag[REId];
00063 
00064          if ( curTag[0] == 0 ) {  //1st signal from detector-unit-REId
00065             curTag[1] = 0x7FFFFFFF;
00066             curTag[2] = 0x7FFFFFFF;
00067             curTag[3] = 0;
00068 
00069             int layer = MdcID::layer(Identifier(TEId));
00070             int wire = MdcID::wire(Identifier(TEId));
00071             //yzhang exchange pre-amplifier
00072             if ( m_runId >= m_runFrom && m_runId <= m_runTo ) {
00073                if (layer == 20 && wire >= 0 && wire <= 7){ 
00074                   TEId = 268456960 + wire;
00075                   curTag[3] |= 0x10;  //16
00076                }
00077                else if (layer == 42 && wire >= 0 && wire <= 7){ 
00078                   TEId = 268478464 + wire;
00079                   curTag[3] |= 0x10;  //16
00080                }
00081                else if (layer == 40 && wire >= 200 && wire <= 207){ 
00082                   TEId += 8;
00083                   curTag[3] |= 0x10;  //16
00084                }
00085                else if (layer == 40 && wire >= 208 && wire <= 215){ 
00086                   TEId -= 8;
00087                   curTag[3] |= 0x10;  //16
00088                }
00089             }
00090 
00091             curTag[0] = (TEId << 2);
00092 
00093             vHits.push_back( REId );
00094          }
00095 
00096          if ( TETorQ == 0 ) {  //T
00097             if ( (curTag[0]&1) == 0 ) {  //1st-found-T
00098                curTag[0] |= 1;
00099                curTag[1] = TEData;
00100                curTag[3] |= TEOverflow;  //0 or 1
00101             }
00102             else {  //multi-T
00103                curTag[3] |= 0xC;  //12, set the multi-T and 1st-T bits
00104                if ( TEData >= curTag[1] ) {
00105                   if ( TEOverflow ) TEData |= (1<<31);  //LastBit
00106                   vmTDC.push_back( make_pair(REId, TEData) );
00107                }
00108                else {
00109                   if ( curTag[3] & 1 ) curTag[1] |= (1<<31);
00110                   vmTDC.push_back( make_pair(REId, curTag[1]) );
00111                   curTag[1] = TEData;
00112                   curTag[3] &= (0xFFFFFFFF-1);
00113                   curTag[3] |= TEOverflow;
00114                }
00115             }
00116          }
00117          else {  //Q
00118             curTag[0] |= 2;
00119             curTag[2] = TEData;
00120             if ( TEOverflow ) curTag[3] |= 2;
00121          }
00122       }
00123    }
00124 
00125    MdcDigi* mdcDigi;
00126    if ( m_runMode == 1 ) {  //OnlineMode, discard the hits that only have T or Q
00127       for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
00128          curTag   = m_mdcTag[it->first];
00129          if ( (curTag[0]&3) == 3 ) {
00130             uint32_t  data  = it->second;
00131             if(data>>31) continue;
00132             mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), (data&0x7FFFFFFF), curTag[2]);
00133             mdcDigi->setOverflow( (curTag[3] & 0x16) | (data>>31) );
00134             des->push_back(mdcDigi);
00135          }
00136       }
00137 
00138       for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
00139          curTag   = m_mdcTag[*it];
00140          if ( (curTag[0]&3) == 3 ) {
00141             if( ((curTag[3]&3)>0) || (((curTag[3]&12)!=12) && ((curTag[3]&12)!=0)) ) {
00142                curTag[0] = 0;
00143                continue; 
00144             }
00145             mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), curTag[1], curTag[2]);
00146             mdcDigi->setOverflow(curTag[3]);
00147             des->push_back(mdcDigi);
00148          }
00149          curTag[0] = 0;
00150       }
00151    }
00152    else {  //Not OnlineMode, keep all the hits found
00153       for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
00154          curTag   = m_mdcTag[it->first];
00155          uint32_t  data     = it->second;
00156          mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), (data&0x7FFFFFFF), curTag[2]);
00157          mdcDigi->setOverflow( (curTag[3] & 0x16) | (data>>31) );
00158          des->push_back(mdcDigi);
00159       }
00160 
00161       for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
00162          curTag   = m_mdcTag[*it];
00163          mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), curTag[1], curTag[2]);
00164          mdcDigi->setOverflow(curTag[3]);
00165          des->push_back(mdcDigi);
00166          curTag[0] = 0;
00167       }
00168    }
00169 
00171    return StatusCode::SUCCESS;
00172 }

void MdcConverter::destroy (  )  [static]

Definition at line 15 of file MdcConverter.cxx.

References s_instance.

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

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

void MdcConverter::init ( int  runFrom,
int  runTo 
)

Definition at line 23 of file MdcConverter.cxx.

References m_mdcTag, m_runFrom, and m_runTo.

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

00024 {
00025    m_runFrom = runFrom;
00026    m_runTo   = runTo;
00027 
00028    memset((void*)m_mdcTag, 0, 16384*4*4);
00029 }

MdcConverter * MdcConverter::instance ( int  runMode = 2  )  [static]

Definition at line 6 of file MdcConverter.cxx.

References MdcConverter(), and s_instance.

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

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

void MdcConverter::setRunId ( int  runId  )  [inline]

Definition at line 19 of file MdcConverter.h.

References m_runId.

Referenced by RawDataMdcDigiCnv::createObj(), and MixerAlg::execute().

00019 { m_runId = runId; }


Member Data Documentation

MdcBuilder MdcConverter::m_builder [private]

Definition at line 41 of file MdcConverter.h.

Referenced by convert().

uint32_t MdcConverter::m_mdcTag[16384][4] [private]

Definition at line 39 of file MdcConverter.h.

Referenced by convert(), and init().

int MdcConverter::m_runFrom [private]

Definition at line 36 of file MdcConverter.h.

Referenced by convert(), and init().

int MdcConverter::m_runId [private]

Definition at line 35 of file MdcConverter.h.

Referenced by convert(), and setRunId().

int MdcConverter::m_runMode [private]

Definition at line 33 of file MdcConverter.h.

Referenced by convert().

int MdcConverter::m_runTo [private]

Definition at line 37 of file MdcConverter.h.

Referenced by convert(), and init().

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

Definition at line 44 of file MdcConverter.h.

Referenced by destroy(), and instance().


Generated on Tue Nov 29 23:20:10 2016 for BOSS_7.0.2 by  doxygen 1.4.7