Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TofMcHitBuilder Class Reference

#include <TofMcHitBuilder.h>

Inheritance diagram for TofMcHitBuilder:

Builder Builder List of all members.

Public Types

typedef std::map< uint32_t,
uint32_t > 
TE2REMAP
typedef std::map< uint32_t,
uint32_t > 
TE2REMAP

Public Member Functions

virtual uint32_t getREID (uint32_t reid)
virtual uint32_t getREID (uint32_t reid)
virtual uint32_t getTEID (uint32_t teid)
virtual uint32_t getTEID (uint32_t teid)
virtual StatusCode initialize (string &initFile)
virtual StatusCode initialize (string &initFile)
virtual StatusCode pack (TofMcHitCol *tofMcHitCol, WriteRawEvent *&re)
virtual StatusCode pack (TofMcHitCol *tofMcHitCol, WriteRawEvent *&re)
 TofMcHitBuilder ()
 TofMcHitBuilder ()
virtual void unPack (vector< uint32_t >::const_iterator &, vector< uint32_t >::const_iterator &, TofTruth_t &)
virtual void unPack (vector< uint32_t >::const_iterator &, vector< uint32_t >::const_iterator &, TofTruth_t &)
virtual ~TofMcHitBuilder ()
virtual ~TofMcHitBuilder ()

Static Public Member Functions

bool expect (ifstream &f, string msg, string fname)
bool expect (ifstream &f, string msg, string fname)
bool expectInt (ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
bool expectInt (ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
bool expectLong (ifstream &f, string msg, string fname, uint64_t &val)
bool expectLong (ifstream &f, string msg, string fname, uint64_t &val)
bool find (ifstream &f, string msg, string fname)
bool find (ifstream &f, string msg, string fname)

Public Attributes

uint64_t m_pxCoeff
uint64_t m_pyCoeff
uint64_t m_pzCoeff
uint64_t m_timeCoeff
uint64_t m_trackLengthCoeff
uint64_t m_xCoeff
uint64_t m_yCoeff
uint64_t m_zCoeff

Protected Member Functions

void append2event (WriteRawEvent *&re, uint32_t source_id, uint32_t size)
void append2event (WriteRawEvent *&re, uint32_t source_id, uint32_t size)

Protected Attributes

uint32_t * m_buf
uint32_t * m_buf
uint32_t m_status

Static Protected Attributes

string m_confFile

Private Member Functions

void makeTofTruth (TofMcHitCol::const_iterator &pTofMcHit, TofTruth_t &tt)
void makeTofTruth (TofMcHitCol::const_iterator &pTofMcHit, TofTruth_t &tt)

Private Attributes

uint32_t m_partIdIndex
uint32_t m_partIdMask
PropertyMgr m_propMgr
uint32_t m_scinNbIndex
uint32_t m_scinNbMask
TE2REMAP m_te2reMap
uint32_t m_trackIndexIndex
uint32_t m_trackIndexMask
vector< int > re2te
vector< int > re2te

Member Typedef Documentation

typedef std::map<uint32_t, uint32_t> Builder::TE2REMAP [inherited]
 

typedef std::map<uint32_t, uint32_t> Builder::TE2REMAP [inherited]
 


Constructor & Destructor Documentation

TofMcHitBuilder::TofMcHitBuilder  ) 
 

00008    :Builder()
00009 {
00010   initialize(Builder::m_confFile);
00011 }

virtual TofMcHitBuilder::~TofMcHitBuilder  )  [inline, virtual]
 

00017 {};

TofMcHitBuilder::TofMcHitBuilder  ) 
 

virtual TofMcHitBuilder::~TofMcHitBuilder  )  [inline, virtual]
 

00017 {};


Member Function Documentation

void Builder::append2event WriteRawEvent *&  re,
uint32_t  source_id,
uint32_t  size
[protected, inherited]
 

void Builder::append2event WriteRawEvent *&  re,
uint32_t  source_id,
uint32_t  size
[protected, inherited]
 

00077 {
00078   uint32_t run_no    = re->run_no();
00079   uint32_t lvl1_id   = re->lvl1_id();
00080   uint32_t bc_id     = 0;   // ?
00081   // ROB
00082   eformat::write::ROBFragment* nrob = new eformat::write::ROBFragment(
00083       source_id,      // source_id
00084       run_no,         // run_no
00085       lvl1_id,        // lvl1_id
00086       bc_id,          // bc_id
00087       0,              // lvl1_type
00088       0,              // detev_type
00089       size,           // ndata
00090       m_buf,          // data
00091       0               // status_position
00092       );
00093   if(m_status==0xFFFFFFFF){
00094     nrob->status(0, NULL);
00095     nrob->rod_status(0, NULL);
00096   }
00097   else{                     //fucd
00098     nrob->status(1, &m_status);
00099     nrob->rod_status(1, &m_status);
00100   }
00101   // ROS
00102   eformat::write::ROSFragment* nros = new eformat::write::ROSFragment(
00103       source_id,      // source_id
00104       run_no,         // run_no
00105       lvl1_id,        // lvl1_id
00106       bc_id           // bc_id
00107       );
00108   if(m_status==0xFFFFFFFF) nros->status(0, NULL);
00109   else        nros->status(1, &m_status);    //fucd
00110   // SubDetector
00111   eformat::write::SubDetectorFragment* nsd = new eformat::write::SubDetectorFragment(source_id);
00112   if(m_status==0xFFFFFFFF) nsd->status(0, NULL);
00113   else        nsd->status(1, &m_status);     //fucd
00114   // append to FullEventFragment
00115   nros->append(nrob);
00116   nsd->append(nros);
00117   re->append(nsd);
00118 }

bool Builder::expect ifstream f,
string  msg,
string  fname
[static, inherited]
 

bool Builder::expect ifstream f,
string  msg,
string  fname
[static, inherited]
 

00029 {
00030   string str;
00031   if( f.bad() ) 
00032   {
00033       cerr << "Error: file " << fname << " is bad" << endl;
00034       return false;
00035   }
00036   f >> str;
00037   if( str == msg )
00038     return true;
00039 
00040   cerr << "Error: expected `" << msg << "|" << str <<"` in " << fname << endl;
00041   return false;
00042 }

bool Builder::expectInt ifstream f,
string  msg,
string  fname,
uint32_t &  val1,
uint32_t &  val2
[static, inherited]
 

bool Builder::expectInt ifstream f,
string  msg,
string  fname,
uint32_t &  val1,
uint32_t &  val2
[static, inherited]
 

00045 {
00046   if( !expect( f, msg, fname ) || f.bad() )
00047     return false;
00048   f >> val1 >> val2;
00049   return true;
00050 }

bool Builder::expectLong ifstream f,
string  msg,
string  fname,
uint64_t &  val
[static, inherited]
 

bool Builder::expectLong ifstream f,
string  msg,
string  fname,
uint64_t &  val
[static, inherited]
 

00053 {
00054   if ( !expect(f, msg, fname) || f.bad() )
00055     return false;
00056   f >> val;
00057   return true;
00058 }

bool Builder::find ifstream f,
string  msg,
string  fname
[static, inherited]
 

bool Builder::find ifstream f,
string  msg,
string  fname
[static, inherited]
 

00061 {
00062   if ( f.bad() ) {
00063     cerr << "Error: file " << fname << " bad checked" << endl;
00064     return false;
00065   }
00066 
00067   string str;
00068   while ( !f.eof() ) {
00069     f >> str;
00070     if ( str == msg ) return true;
00071   }
00072 
00073   return false;
00074 }

virtual uint32_t TofMcHitBuilder::getREID uint32_t  reid  )  [virtual]
 

Implements Builder.

uint32_t TofMcHitBuilder::getREID uint32_t  reid  )  [virtual]
 

Implements Builder.

00120 {
00121   return 0;
00122 }

virtual uint32_t TofMcHitBuilder::getTEID uint32_t  teid  )  [virtual]
 

Implements Builder.

uint32_t TofMcHitBuilder::getTEID uint32_t  teid  )  [virtual]
 

Implements Builder.

00114 {
00115   return 0;
00116 }

virtual StatusCode TofMcHitBuilder::initialize string &  initFile  )  [virtual]
 

Reimplemented from Builder.

StatusCode TofMcHitBuilder::initialize string &  initFile  )  [virtual]
 

Reimplemented from Builder.

00076 {
00077   ifstream f;
00078 
00079   //read init file
00080   f.open(initFile.c_str());
00081 
00082   if ( f.bad() ) {
00083     cerr   << "Error: could not open file " << initFile << endl;
00084     return StatusCode::FAILURE;
00085   }
00086 
00087   if (!Builder::find( f, "##TofTruthConf", initFile)) {
00088     cerr << "Error: could not find '##TofTruthConf' in file " << initFile << endl;
00089     return StatusCode::FAILURE;
00090   }
00091 
00092   if ( !Builder::expect( f, "#TofTruthShift", initFile) ||
00093        !Builder::expectInt( f, "trackIndex", initFile, m_trackIndexIndex, m_trackIndexMask) ||
00094        !Builder::expectInt( f, "partId", initFile, m_partIdIndex, m_partIdMask) ||
00095        !Builder::expectInt( f, "scinNb", initFile, m_scinNbIndex, m_scinNbMask) ||
00096        !Builder::expect( f, "#TofTruthCoeff", initFile) ||
00097        !Builder::expectLong( f, "x", initFile, m_xCoeff) ||
00098        !Builder::expectLong( f, "y", initFile, m_yCoeff) ||
00099        !Builder::expectLong( f, "z", initFile, m_zCoeff) ||
00100        !Builder::expectLong( f, "px", initFile, m_pxCoeff) ||
00101        !Builder::expectLong( f, "py", initFile, m_pyCoeff) ||
00102        !Builder::expectLong( f, "pz", initFile, m_pzCoeff) ||
00103        !Builder::expectLong( f, "trackLength", initFile, m_trackLengthCoeff) ||
00104        !Builder::expectLong( f, "time", initFile, m_timeCoeff)   )
00105     return StatusCode::FAILURE;
00106 
00107   f.close();
00108 
00109   return StatusCode::SUCCESS;
00110 }

void TofMcHitBuilder::makeTofTruth TofMcHitCol::const_iterator &  pTofMcHit,
TofTruth_t tt
[private]
 

void TofMcHitBuilder::makeTofTruth TofMcHitCol::const_iterator &  pTofMcHit,
TofTruth_t tt
[private]
 

00126 {
00127   Identifier ident = (*pTofMcHit)->identify();
00128 
00129   uint32_t layer     = TofID::layer(ident);
00130   uint32_t scinNum   = TofID::phi_module(ident);
00131   //if (layer == 1) scinNum += 88;
00132   if (TofID::is_barrel(layer)) scinNum += TofID::getPHI_BARREL_MAX() + 1;
00133 
00134   tt.trackIndex = (*pTofMcHit)->getTrackIndex();
00135   tt.partId     = TofID::barrel_ec(ident);
00136   tt.scinNb     = scinNum;
00137   tt.x          = int((*pTofMcHit)->getPositionX() * m_xCoeff);
00138   tt.y          = int((*pTofMcHit)->getPositionY() * m_yCoeff);
00139   tt.z          = int((*pTofMcHit)->getPositionZ() * m_zCoeff);
00140   tt.px         = int((*pTofMcHit)->getPx() * m_pxCoeff);
00141   tt.py         = int((*pTofMcHit)->getPy() * m_pyCoeff);
00142   tt.pz         = int((*pTofMcHit)->getPz() * m_pzCoeff);
00143   tt.trackLength= int((*pTofMcHit)->getTrackLength() * m_trackLengthCoeff);
00144   tt.time       = int((*pTofMcHit)->getFlightTime() * m_timeCoeff);
00145 
00146   return;
00147 }

virtual StatusCode TofMcHitBuilder::pack TofMcHitCol tofMcHitCol,
WriteRawEvent *&  re
[virtual]
 

StatusCode TofMcHitBuilder::pack TofMcHitCol tofMcHitCol,
WriteRawEvent *&  re
[virtual]
 

00035 {
00036 /*
00037   if (tofMcHitCol == NULL) {
00038     cout << "TofMcHitBuilder::pack cant get TofMcHitCol" << endl;
00039     return StatusCode::FAILURE;
00040   }
00041 
00042   vector<uint32_t> *tofReMcHitVec = new vector<uint32_t>;
00043   TofTruth_t m_TofTruth;
00044 
00045   TofMcHitCol::const_iterator pTofMcHit = tofMcHitCol->begin();
00046   for ( ; pTofMcHit != tofMcHitCol->end(); pTofMcHit++) {
00047     // make TofTruth_t data
00048     makeTofTruth(pTofMcHit, m_TofTruth);
00049     //pack the int numbers
00050     uint32_t helpVal = (m_TofTruth.trackIndex<<m_trackIndexIndex) & m_trackIndexMask;
00051     helpVal |= ((m_TofTruth.partId<<m_partIdIndex) & m_partIdMask);
00052     helpVal |= ((m_TofTruth.scinNb<<m_scinNbIndex) & m_scinNbMask);
00053     //fill the McHit vector
00054     tofReMcHitVec->push_back(helpVal);
00055     tofReMcHitVec->push_back(m_TofTruth.x);
00056     tofReMcHitVec->push_back(m_TofTruth.y);
00057     tofReMcHitVec->push_back(m_TofTruth.z);
00058     tofReMcHitVec->push_back(m_TofTruth.px);
00059     tofReMcHitVec->push_back(m_TofTruth.py);
00060     tofReMcHitVec->push_back(m_TofTruth.pz);
00061     tofReMcHitVec->push_back(m_TofTruth.trackLength);
00062     tofReMcHitVec->push_back(m_TofTruth.time);
00063   }
00064 
00065   OfflineEventFormat::SubDetectorHeader sh(OfflineEventFormat::TOFTRUTH);
00066   SubRawEvent *sub = new SubRawEvent(sh, tofReMcHitVec);
00067   re->append(sub);
00068 */
00069 
00070   return StatusCode::SUCCESS;
00071 }

virtual void TofMcHitBuilder::unPack vector< uint32_t >::const_iterator &  ,
vector< uint32_t >::const_iterator &  ,
TofTruth_t
[virtual]
 

void TofMcHitBuilder::unPack vector< uint32_t >::const_iterator &  ,
vector< uint32_t >::const_iterator &  ,
TofTruth_t
[virtual]
 

00015 {
00016   uint32_t helpVal = *(iter++); assert(iter != eiter);
00017   tt.x          = *(iter++); assert(iter != eiter);
00018   tt.y          = *(iter++); assert(iter != eiter);
00019   tt.z          = *(iter++); assert(iter != eiter);
00020   tt.px         = *(iter++); assert(iter != eiter);
00021   tt.py         = *(iter++); assert(iter != eiter);
00022   tt.pz         = *(iter++); assert(iter != eiter);
00023   tt.trackLength= *(iter++); assert(iter != eiter);
00024   tt.time       = *(iter++);
00025 
00026   tt.trackIndex = (helpVal&m_trackIndexMask) >> m_trackIndexIndex;
00027   tt.partId     = (helpVal&m_partIdMask) >> m_partIdIndex; 
00028   tt.scinNb     = (helpVal&m_scinNbMask) >> m_scinNbIndex;
00029 
00030   return;
00031 }


Member Data Documentation

uint32_t* Builder::m_buf [protected, inherited]
 

uint32_t* Builder::m_buf [protected, inherited]
 

string Builder::m_confFile [static, protected, inherited]
 

uint32_t TofMcHitBuilder::m_partIdIndex [private]
 

uint32_t TofMcHitBuilder::m_partIdMask [private]
 

PropertyMgr TofMcHitBuilder::m_propMgr [private]
 

Reimplemented from Builder.

uint64_t TofMcHitBuilder::m_pxCoeff
 

uint64_t TofMcHitBuilder::m_pyCoeff
 

uint64_t TofMcHitBuilder::m_pzCoeff
 

uint32_t TofMcHitBuilder::m_scinNbIndex [private]
 

uint32_t TofMcHitBuilder::m_scinNbMask [private]
 

uint32_t Builder::m_status [protected, inherited]
 

TE2REMAP TofMcHitBuilder::m_te2reMap [private]
 

uint64_t TofMcHitBuilder::m_timeCoeff
 

uint32_t TofMcHitBuilder::m_trackIndexIndex [private]
 

uint32_t TofMcHitBuilder::m_trackIndexMask [private]
 

uint64_t TofMcHitBuilder::m_trackLengthCoeff
 

uint64_t TofMcHitBuilder::m_xCoeff
 

uint64_t TofMcHitBuilder::m_yCoeff
 

uint64_t TofMcHitBuilder::m_zCoeff
 

vector<int> TofMcHitBuilder::re2te [private]
 

vector<int> TofMcHitBuilder::re2te [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 18:59:23 2011 for BOSS6.5.5 by  doxygen 1.3.9.1