6 #include "EVENT/LCIO.h"
12 using namespace EVENT ;
13 using namespace IMPL ;
16 #define IDRUP_NAME "_idrup"
17 #define EVTWGT_NAME "_weight"
21 LCStdHepRdr::LCStdHepRdr(
const char* evfile){
26 if(_reader->getError()) {
28 description <<
"LCStdHepRdr: no stdhep file: " << evfile <<
std::ends ;
35 LCStdHepRdr::~LCStdHepRdr(){
45 _reader->printFileHeader() ;
55 throw EVENT::Exception(
" LCStdHepRdr::updateEvent - null pointer for event " );
90 double c_light = 299.792;
96 int errorcode = _reader->readEvent() ;
103 description <<
"LCStdHepRdr::readEvent: error when reading event: " << errorcode <<
std::ends ;
133 int NHEP = _reader->nTracks();
136 long idrup = _reader->idrup() ;
159 double evtWeight = _reader->eventweight() ;
166 for(
int IHEP=0; IHEP<NHEP; IHEP++ )
174 mcVec->
at(IHEP) = mcp ;
179 mcp->
setPDG(_reader->pid(IHEP));
190 float p0[3] = {(float)_reader->Px(IHEP),(float)_reader->Py(IHEP),(float)_reader->Pz(IHEP)};
195 mcp->
setMass(_reader->M(IHEP));
199 double v0[3] = {_reader->X(IHEP),_reader->Y(IHEP),_reader->Z(IHEP)};
212 mcp->
setTime(_reader->T(IHEP)/c_light);
216 if( _reader->isStdHepEv4() ){
218 float spin[3] = {(float) _reader->spinX( IHEP ) ,(float) _reader->spinY( IHEP ) , (float) _reader->spinZ( IHEP ) } ;
221 int colorFlow[2] = { (int)_reader->colorflow( IHEP , 0 ) , (int)_reader->colorflow( IHEP , 1 ) } ;
304 for(
int IHEP=0; IHEP<NHEP; IHEP++ )
316 int fd = _reader->daughter1(IHEP)%10000 - 1;
317 int ld = _reader->daughter2(IHEP)%10000 - 1;
327 if( (fd > -1) && (ld > -1) )
331 for(
int id=fd;
id<ld+1;
id++)
341 for(
int ip=0;ip < np;ip++)
345 if(p == mcp)gotit =
true;
362 for(
int ip=0;ip < np;ip++)
366 if(p == mcp)gotit =
true;
373 for(
int ip=0;ip < np;ip++)
377 if(p == mcp)gotit =
true;
390 for(
int ip=0;ip < np;ip++)
394 if(p == mcp)gotit =
true;
438 for(
int IHEP=0; IHEP<NHEP; IHEP++ ){
449 if ((nic>0) && (mcp->
getPDG()==94)) {
452 int parentid = _reader->mother1(IHEP)%10000 - 1;
453 int firstdau = _reader->daughter1(IHEP)%10000 - 1;
454 int lastdau = _reader->daughter2(IHEP)%10000 - 1;
455 unsigned outn = ( ( lastdau-firstdau +1 ) > 0 ? lastdau-firstdau +1 : 0 ) ;
461 for (
unsigned int nextparentid = parentid; IHEP-nextparentid>0; nextparentid++){
493 int LCStdHepRdr::threeCharge(
int pdgID )
const {
500 enum location { nj=1, nq3, nq2, nq1, nl, nr, n, n8, n9, n10 };
504 unsigned short q1, q2, q3;
505 static const int ch100[100] = { -1, 2,-1, 2,-1, 2,-1, 2, 0, 0,
506 -3, 0,-3, 0,-3, 0,-3, 0, 0, 0,
507 0, 0, 0, 3, 0, 0, 0, 0, 0, 0,
508 0, 0, 0, 3, 0, 0, 3, 0, 0, 0,
509 0, -1, 0, 0, 0, 0, 0, 0, 0, 0,
510 0, 6, 3, 6, 0, 0, 0, 0, 0, 0,
511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
512 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
513 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
514 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
516 ida = (pdgID < 0) ? -pdgID : pdgID ;
522 q1 = ( ida / ( (int)
std::pow( 10.0, (nq1 -1) ) ) ) % 10 ;
523 q2 = ( ida / ( (int)
std::pow( 10.0, (nq2 -1) ) ) ) % 10 ;
524 q3 = ( ida / ( (int)
std::pow( 10.0, (nq3 -1) ) ) ) % 10 ;
528 short dig_n9 = ( ida / ( (int)
std::pow( 10.0, (n9 -1) ) ) ) % 10 ;
529 short dig_n10 = ( ida / ( (int)
std::pow( 10.0, (n10 -1) ) ) ) % 10 ;
531 if( ( dig_n10 == 1 ) && ( dig_n9 == 0 ) ) {
535 else if( q2 == 0 && q1 == 0) {
539 else if( ida <= 102 ) {
549 int extraBits = ida / 10000000 ;
552 short dig_nj = ( ida / ( (int)
std::pow( 10.0, (nj -1) ) ) ) % 10 ;
554 if( ida == 0 || extraBits > 0 ) {
556 }
else if( sid > 0 && sid <= 100 ) {
557 charge = ch100[sid-1];
558 if(ida==1000017 || ida==1000018) { charge = 0; }
559 if(ida==1000034 || ida==1000052) { charge = 0; }
560 if(ida==1000053 || ida==1000054) { charge = 0; }
561 if(ida==5100061 || ida==5100062) { charge = 6; }
562 }
else if( dig_nj == 0 ) {
564 }
else if( q1 == 0 ) {
565 if( q2 == 3 || q2 == 5 ) {
566 charge = ch100[q3-1] - ch100[q2-1];
568 charge = ch100[q2-1] - ch100[q3-1];
570 }
else if( q3 == 0 ) {
571 charge = ch100[q2-1] + ch100[q1-1];
573 charge = ch100[q3-1] + ch100[q2-1] + ch100[q1-1];
577 }
else if( pdgID < 0 ) {
Base exception class for LCIO - all other exceptions extend this.
virtual EVENT::LCParameters & parameters()
Parameters defined for this run.
virtual EVENT::LCObject * getElementAt(int index) const
Returns pointer to element at index - no range check !.
void setWeight(double w)
Set the event weight.
void setTime(float time)
Sets the createion time.
Implementation of the LCCollection using (inheriting from) an STL vector of LCObjects.
Implementation of the main event class.
virtual const EVENT::LCParameters & getParameters() const
Parameters defined for this run.
virtual const EVENT::MCParticleVec & getParents() const
Returns the parents of this particle.
virtual int getGeneratorStatus() const
Returns the status for particles from the generator 0 empty line 1 undecayed particle, stable in the generator 2 particle decayed in the generator 3 documentation line.
void setGeneratorStatus(int status)
Sets the Generator status.
void addParent(EVENT::MCParticle *mom)
Adds a parent particle.
virtual void addCollection(EVENT::LCCollection *col, const std::string &name)
Adds a collection with the given name (has to be a valid C/C++ variable name).
void setColorFlow(const int cflow[2])
Sets the color flow.
void setSimulatorStatus(int status)
Sets the Simulator status.
void setMass(float m)
Sets the mass.
void setMomentum(const float p[3])
Sets the momentum.
IOException used for reading/writing errors.
void setVertex(const double vtx[3])
Sets the production vertex.
virtual void setValue(const std::string &key, int value)=0
Set integer value for the given key.
virtual float getFloatVal(const std::string &key) const =0
Returns the first float value for the given key.
void setCharge(float c)
Sets the charge.
virtual const EVENT::MCParticleVec & getDaughters() const
Returns the daughters of this particle.
virtual EVENT::LCParameters & parameters()
Parameters defined for this run.
void setPDG(int pdg)
Sets the parent.
virtual int getIntVal(const std::string &key) const =0
Returns the first integer value for the given key.
EndOfDataException for signaling the end of a data stream.
void setSpin(const float spin[3])
Sets the spin.
virtual int getPDG() const
Returns the number of daughters of this particle.
Implementation of MCParticle.