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

McParticleBuilder Class Reference

#include <McParticleBuilder.h>

Inheritance diagram for McParticleBuilder:

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)
 McParticleBuilder ()
 McParticleBuilder ()
virtual StatusCode pack (McParticleCol *mcParticleCol, WriteRawEvent *&re)
virtual StatusCode pack (McParticleCol *mcParticleCol, WriteRawEvent *&re)
virtual void unPack (uint32_t *buf, double *vPointer, McParticle *mcPar)
virtual void unPack (uint32_t *buf, double *vPointer, McParticle *mcPar)
virtual ~McParticleBuilder ()
virtual ~McParticleBuilder ()

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)

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
PropertyMgr m_propMgr
uint32_t m_status

Static Protected Attributes

string m_confFile

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

McParticleBuilder::McParticleBuilder  ) 
 

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

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

00016 {};

McParticleBuilder::McParticleBuilder  ) 
 

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

00016 {};


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 McParticleBuilder::getREID uint32_t  reid  )  [virtual]
 

Implements Builder.

uint32_t McParticleBuilder::getREID uint32_t  reid  )  [virtual]
 

Implements Builder.

00139 {
00140   return 0;
00141 }

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

Implements Builder.

uint32_t McParticleBuilder::getTEID uint32_t  teid  )  [virtual]
 

Implements Builder.

00133 {
00134   return 0;
00135 }

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

Reimplemented from Builder.

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

Reimplemented from Builder.

00110 {
00111   ifstream f;
00112 
00113   //read init file
00114   f.open(initFile.c_str());
00115 
00116   if ( f.bad() ) {
00117     cerr   << "Error: could not open file " << initFile << endl;
00118     return StatusCode::FAILURE;
00119   }
00120 
00121   if (!Builder::find( f, "##McParticleConf", initFile)) {
00122     cerr << "Error: could not find '##McParticleConf' in file " << initFile << endl;
00123     return StatusCode::FAILURE;
00124   }
00125 
00126   f.close();                    
00127                                   
00128   return StatusCode::SUCCESS;     
00129 }

virtual StatusCode McParticleBuilder::pack McParticleCol mcParticleCol,
WriteRawEvent *&  re
[virtual]
 

StatusCode McParticleBuilder::pack McParticleCol mcParticleCol,
WriteRawEvent *&  re
[virtual]
 

00042 {
00043   if (mcParticleCol == 0 ) {
00044     cerr << "McParticleBuilder::pack can't get mcParticleCol" << endl;
00045     return StatusCode::FAILURE;
00046   }
00047 
00048   uint32_t nParticle = mcParticleCol->size();
00049   uint32_t nVertex = 0;
00050   vector<bool> vFlag(nParticle+1, false);
00051   double*  vPointer = (double*)(m_buf + nParticle*11 + 1);
00052 
00053   uint32_t index = 0;
00054   int tIndex, vIndex0, vIndex1;
00055   int parId;
00056   uint32_t statusFlag;
00057 
00058   m_buf[index++] = (nParticle<<16);
00059 
00060   McParticleCol::const_iterator itPar = mcParticleCol->begin();
00061   for( ; itPar != mcParticleCol->end(); itPar++) {
00062     tIndex  = (*itPar)->trackIndex();
00063     vIndex0 = (*itPar)->vertexIndex0();
00064     vIndex1 = (*itPar)->vertexIndex1();
00065     if (vIndex1 == -99) vIndex1 = 0xFF;
00066     parId   = (*itPar)->particleProperty();
00067     statusFlag = (*itPar)->statusFlags();
00068     const HepLorentzVector& p4vec    = (*itPar)->initialFourMomentum();
00069     m_buf[index++] = ((tIndex<<16) | (vIndex0<<8) | (vIndex1));
00070     m_buf[index++] = (uint32_t)parId;
00071     m_buf[index++] = statusFlag;
00072     double* ptmp = (double*)(m_buf+index);
00073     ptmp[0] = p4vec.x();
00074     ptmp[1] = p4vec.y();
00075     ptmp[2] = p4vec.z();
00076     ptmp[3] = p4vec.t();
00077     index += 8;
00078 
00079     if ( !vFlag[vIndex0] ) {
00080       const HepLorentzVector& initPos  = (*itPar)->initialPosition();
00081       vPointer[vIndex0*4 + 0] = initPos.px();
00082       vPointer[vIndex0*4 + 1] = initPos.py();
00083       vPointer[vIndex0*4 + 2] = initPos.pz();
00084       vPointer[vIndex0*4 + 3] = initPos.e();
00085       vFlag[vIndex0] = true;
00086       nVertex++;
00087     }
00088 
00089     if ( (vIndex1 != 0xFF) && (!vFlag[vIndex1]) ) {
00090       const HepLorentzVector& finalPos = (*itPar)->finalPosition();
00091       vPointer[vIndex1*4 + 0] = finalPos.px();
00092       vPointer[vIndex1*4 + 1] = finalPos.py();
00093       vPointer[vIndex1*4 + 2] = finalPos.pz();
00094       vPointer[vIndex1*4 + 3] = finalPos.e();
00095       vFlag[vIndex1] = true;
00096       nVertex++;
00097     }
00098   }
00099 
00100   m_buf[0] |= nVertex;
00101 
00102   append2event(re, 0xf10000, (nParticle*11 + nVertex*8 + 1));
00103 
00104   return StatusCode::SUCCESS;
00105 }

virtual void McParticleBuilder::unPack uint32_t *  buf,
double *  vPointer,
McParticle mcPar
[virtual]
 

void McParticleBuilder::unPack uint32_t *  buf,
double *  vPointer,
McParticle mcPar
[virtual]
 

00013 {
00014   uint32_t trkIndex = (buf[0]>>16);
00015   uint32_t vIndex0  = (buf[0]>>8) & 0xFF;
00016   uint32_t vIndex1  = buf[0] & 0xFF;
00017 
00018   double*  ptmp      = (double*)(buf+3);
00019   double*  v0Pointer = vPointer + 4*vIndex0;
00020   HepLorentzVector initMomentum(ptmp[0], ptmp[1], ptmp[2], ptmp[3]);
00021   HepLorentzVector initPosition(v0Pointer[0], v0Pointer[1], v0Pointer[2], v0Pointer[3]);
00022 
00023   mcPar->initialize(buf[1], buf[2], initMomentum, initPosition, "");
00024   mcPar->setTrackIndex(trkIndex);
00025   mcPar->setVertexIndex0(vIndex0);
00026 
00027   if (vIndex1 == 0xFF) {
00028     mcPar->setVertexIndex1(-99);
00029   }
00030   else {
00031     mcPar->setVertexIndex1(vIndex1);
00032 
00033     double* v1Pointer = vPointer + 4*vIndex1;
00034     HepLorentzVector finalPosition(v1Pointer[0], v1Pointer[1], v1Pointer[2], v1Pointer[3]);
00035     mcPar->finalize(finalPosition);
00036   }
00037 
00038   return;
00039 }


Member Data Documentation

uint32_t* Builder::m_buf [protected, inherited]
 

uint32_t* Builder::m_buf [protected, inherited]
 

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

PropertyMgr Builder::m_propMgr [protected, inherited]
 

Reimplemented in EmcBuilder, EmcMcHitBuilder, HltBuilder, MdcBuilder, MdcMcHitBuilder, MucBuilder, MucMcHitBuilder, TofBuilder, and TofMcHitBuilder.

uint32_t Builder::m_status [protected, inherited]
 


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