EventTagSvc Class Reference

#include <EventTagSvc.h>

Inheritance diagram for EventTagSvc:

IEventTagSvc List of all members.

Public Member Functions

 EventTagSvc (const std::string &name, ISvcLocator *svc)
StatusCode initialize ()
std::string pdg2name (long int pdg)
long int name2pdg (std::string pname)
StatusCode finalize ()
int getDecayCode (Event::McParticle *part)
unsigned long long int getChainCode (Event::McParticle *part)
unsigned int getCharmDecayType (Event::McParticle *part)
virtual StatusCode queryInterface (const InterfaceID &, void **ppvInterface)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

int readPdtFile (std::string fname)
int readDecayTabFile (std::string fname)
int buildAntiPartTabs ()

Private Attributes

std::string m_decayTabsFile
std::string m_pdtFile
std::string m_userDecayTabsFile
bool m_buildAntiTabs
bool m_ignorePhotons
bool m_ignoreFSR
bool m_digK0
std::vector< std::stringuserChainTrig
std::map< int, decayModeTab * > m_decayTabList
std::map< std::string, long
int > 
name2pdgTab
std::map< long int, std::stringpdg2nameTab
std::set< long int > chainTrigParticles

Detailed Description

Definition at line 26 of file EventTagSvc.h.


Constructor & Destructor Documentation

EventTagSvc::EventTagSvc ( const std::string name,
ISvcLocator *  svc 
)

Definition at line 22 of file EventTagSvc.cxx.

References m_buildAntiTabs, m_decayTabsFile, m_digK0, m_ignoreFSR, m_ignorePhotons, m_pdtFile, m_userDecayTabsFile, and userChainTrig.

00022                                                                  :
00023   Service(name,svc)
00024 {
00025 
00026   declareProperty("pdgFile", m_pdtFile="pdt.table");
00027   declareProperty("decayCodesFile", m_decayTabsFile="decay.codes");
00028   //  declareProperty("userDecayCodesFile", 
00029   //                            m_userDecayTabsFile="userdecay.codes");
00030   declareProperty("userDecayCodesFile", m_userDecayTabsFile="");
00031   declareProperty("buildAntiPartTable", m_buildAntiTabs=true);
00032   declareProperty("ignorePhotons", m_ignorePhotons=true);
00033   declareProperty("ignoreFSR", m_ignoreFSR=true);
00034   declareProperty("chainTrigParticles", userChainTrig);
00035   declareProperty("digK0", m_digK0=true);
00036 }
#else  // BEAN


Member Function Documentation

int EventTagSvc::buildAntiPartTabs (  )  [private]

Definition at line 659 of file EventTagSvc.cxx.

References calibUtil::ERROR, Bes_Common::INFO, m_decayTabList, msgSvc(), pdg2name(), and delete_small_size::size.

Referenced by initialize().

00659                                   {
00660 #ifndef BEAN
00661   MsgStream log(msgSvc(), name());
00662 #endif
00663   decayModeTab* dTab;
00664   decayModeTab* adTab;
00665   keyVector key,akey;
00666   int mother,amother,code;
00667   for(std::map<int,decayModeTab*>::iterator itl=m_decayTabList.begin(); 
00668       itl!=m_decayTabList.end();itl++){
00669     mother=itl->first;
00670     amother=-mother;
00671     if(m_decayTabList.find(amother)!=m_decayTabList.end())
00672       continue;// aparticle tab already exist
00673     if(pdg2name(mother).size()==0){
00674 #ifndef BEAN
00675       log<<MSG::ERROR
00676       <<" buildAntiPartTabs :: Unknown pdg code for mother particle "<<endreq;
00677 #else
00678       cerr << " buildAntiPartTabs :: Unknown pdg code for mother particle " 
00679            << endl;
00680 #endif
00681       return 1;
00682     }
00683     if(pdg2name(amother).size()==0)continue; //Aparticle==particle??
00684 #ifndef BEAN
00685     log<<MSG::INFO<<" buildAntiPartTabs :: create new table for particle "
00686        << amother<<"("<<pdg2name(amother)<<")"<<endreq;
00687 #else
00688     if (verbose)
00689       cout << " buildAntiPartTabs :: create new table for particle "
00690            << amother << "(" << pdg2name (amother) << ")" << endl;
00691 #endif
00692     dTab=itl->second;
00693     adTab=new decayModeTab;
00694     m_decayTabList[amother]=adTab;
00695     key.clear();
00696     for(decayModeTab::iterator it=dTab->begin();it!=dTab->end();it++){
00697       key=it->first;
00698       code=it->second;
00699       for(keyVector::iterator it=key.begin();it!=key.end();it++){
00700         if(pdg2name(*it).size()==0){
00701 #ifndef BEAN
00702           log<<MSG::ERROR<<" buildAntiPartTabs :: Unknown pdg code"
00703              << "for  particle in keyVector"<<endreq;
00704 #else
00705           cerr << " buildAntiPartTabs :: Unknown pdg code"
00706                << "for  particle in keyVector" << endl;
00707 #endif
00708           return 1;
00709         }
00710         if(pdg2name(-(*it)).size()==0)continue ; // true neutral ??
00711         (*it) *= -1;
00712       }
00713       sort(key.begin(),key.end());
00714       (*adTab)[key]=code;
00715     }
00716   }
00717   return 0;
00718 }

StatusCode EventTagSvc::finalize (  ) 

Definition at line 184 of file EventTagSvc.cxx.

References Bes_Common::INFO, and msgSvc().

00184                                  {
00185   // Part 1: Get the messaging service, print where you are
00186   MsgStream log(msgSvc(), name());
00187   log << MSG::INFO << "EventTagSvc finalize()" << endreq;
00188   return StatusCode::SUCCESS;
00189 }

unsigned long long int EventTagSvc::getChainCode ( Event::McParticle part  )  [virtual]

Implements IEventTagSvc.

Definition at line 807 of file EventTagSvc.cxx.

References abs, chainTrigParticles, getCharmDecayType(), TMcParticle::getDaughters(), getDecayCode(), genRecEmupikp::i, and mcPartPrtLess().

00807                                                                      {
00808 #else
00809 unsigned long long int EventTagSvc::getChainCode (TMcParticle * part){
00810    if (!m_TMcEvent) {
00811       cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
00812       return -1;
00813    }
00814 #endif
00815   unsigned long long int code=0;
00816   int shift=0;
00817 #ifndef BEAN
00818   vector<Event::McParticle*> chainVect;
00819 #else
00820   vector < TMcParticle * >chainVect;
00821 #endif
00822   while(shift<57){
00823     code |=  (getDecayCode(part)&0xFF)<<shift;  
00824 #ifndef BEAN
00825     SmartRefVector<Event::McParticle> dref=part->daughterList();
00826 #else
00827     vector < int >dref = part->getDaughters ();
00828 #endif
00829     chainVect.clear();
00830 #ifndef BEAN
00831     for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();
00832      it!=dref.end();it++){
00833       int abspdg=abs((*it)->particleProperty());
00834 #else
00835     for (unsigned int i = 0; i < dref.size (); i++) {
00836       const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
00837 
00838       int abspdg = abs (daughter->getParticleID ());
00839 #endif
00840       if(((((abspdg%1000)/10)<45) && (((abspdg%1000)/10)>40)) // select particles with *4?? pdg code
00841          ||(chainTrigParticles.find(abspdg)!=chainTrigParticles.end())) { 
00842 #ifndef BEAN
00843         chainVect.push_back(*it);
00844 #else
00845         chainVect.push_back (const_cast < TMcParticle * >(daughter));
00846 #endif
00847       }
00848     }
00849     if(chainVect.size()==0 ||chainVect.size()>2)break;
00850     if(chainVect.size()==1){part=chainVect[0];}
00851     else{
00852       sort(chainVect.begin(),chainVect.end(),mcPartPrtLess);
00853       code |= ((getDecayCode(chainVect[0])&0xFF)<<(shift+8));
00854       code |= ((getDecayCode(chainVect[1])&0xFF)<<(shift+16));
00855       break;
00856     }
00857     shift+=8;
00858   }
00859   return code;
00860 }

unsigned int EventTagSvc::getCharmDecayType ( Event::McParticle part  )  [virtual]

Implements IEventTagSvc.

Definition at line 721 of file EventTagSvc.cxx.

References abs, TMcParticle::getDaughters(), genRecEmupikp::i, and m_ignorePhotons.

Referenced by getChainCode().

00721                                                                  {
00722 #else
00723 unsigned int EventTagSvc::getCharmDecayType (TMcParticle * part){
00724    if (!m_TMcEvent) {
00725       cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
00726       return -1;
00727    }
00728 #endif
00729   unsigned int a=0;
00730   //  int type=0;
00731   if(! part) return 0xF;
00732 #ifndef BEAN
00733   SmartRefVector<Event::McParticle> dref=part->daughterList();
00734 #else
00735   vector < int >dref = part->getDaughters ();
00736 #endif
00737   if(dref.size()==0) return 0;
00738   int nhad=0;
00739   long int pdg1=0;
00740   bool dd=false;
00741 #ifndef BEAN
00742   for(SmartRefVector<Event::McParticle>::iterator it=dref.begin(); 
00743    it!=dref.end();it++){
00744     int pdg=abs((*it)->particleProperty());
00745 #else
00746   for (unsigned int i = 0; i < dref.size (); i++) {
00747     const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
00748 
00749     int pdg = abs (daughter->getParticleID ());
00750 #endif
00751     if((pdg==22)&&m_ignorePhotons)continue;
00752     if(pdg==22){a|=1;}
00753     else if( (pdg>10)&&(pdg<19) ){a |=(1<<1);}
00754     else if( pdg>110) {
00755       if( ((pdg%1000)/100==4)&&((pdg%100)/10==4)){
00756         a |= 1<<3;
00757       }
00758       else{
00759         a |= 1<<2;
00760         nhad+=1;
00761         if(nhad==1)pdg1=pdg;
00762         dd=(pdg1==pdg);
00763       }
00764     }
00765     else a |=1<<4;
00766   }
00767   if(a>0xF)return 0xf;        //unknown particle
00768   if(a==4){                   //  hadronic
00769     if((nhad!=2)||(!dd))return 6;
00770     //    long int pdg1=dref[0]->particleProperty();
00771     //    long int pdg2=dref[1]->particleProperty();
00772     //    if(abs(pdg1)!=abs(pdg2)) return 6;
00773     switch (abs(pdg1)){
00774     case 411:
00775       return 7;
00776       break;
00777     case 421:
00778       return 8;
00779       break;
00780     case 413:
00781       return 9;
00782       break;
00783     case 423:
00784       return 10;
00785       break;
00786     case 431:
00787       return 11;
00788       break;
00789     case 433:
00790       return 12;
00791       break;
00792     default:
00793       return 6;
00794       break;
00795     }
00796   }
00797   if((a&0xE)==2)return 1;     // leptonic 
00798   if((a&0x6)==0x6)return 2;   // semileptonic 
00799   if((a&0xE)==0xC)return 4;   //  hadronic charmonium transition
00800   if((a&0xE)==0x8)return 3;   //  radiative charmonium transition   !!use 0XE mask for correct work with "ignore photons" options; 
00801   if((a&1)==1)return 5;       //  radiative
00802   return 0xf;                 //unknown
00803 }

int EventTagSvc::getDecayCode ( Event::McParticle part  )  [virtual]

Implements IEventTagSvc.

Definition at line 588 of file EventTagSvc.cxx.

References abs, TMcParticle::getDaughters(), TMcParticle::getParticleID(), genRecEmupikp::i, m_decayTabList, m_digK0, m_ignoreFSR, m_ignorePhotons, msgSvc(), and Bes_Common::WARNING.

Referenced by getChainCode().

00588                                                   {
00589   MsgStream log(msgSvc(), name());
00590 #else
00591 int EventTagSvc::getDecayCode (TMcParticle * part){
00592    if (!m_TMcEvent) {
00593       cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
00594       return -1;
00595    }
00596 #endif
00597   keyVector key;
00598 
00599 #ifndef BEAN
00600   long int mother_pdg=part->particleProperty();
00601 #else
00602   long int mother_pdg = part->getParticleID ();
00603 #endif
00604 
00605   map<int,decayModeTab*>::iterator itlist=m_decayTabList.find(mother_pdg);
00606   if(itlist==m_decayTabList.end())return 0;
00607   decayModeTab* dTab=itlist->second;
00608 
00609 #ifndef BEAN
00610   SmartRefVector<Event::McParticle> dref=part->daughterList();
00611 #else
00612   vector < int >dref = part->getDaughters ();
00613 #endif
00614   if(dref.size()==0)return 0;
00615   key.clear();
00616 
00617 #ifndef BEAN
00618   for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();
00619    it!=dref.end();it++){
00620     int pdg=(*it)->particleProperty();
00621 #else
00622    for (unsigned int i = 0; i < dref.size (); i++) {
00623       const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
00624 
00625       int pdg = daughter->getParticleID ();
00626 #endif
00627     if(m_digK0&&(abs(pdg)==311)){
00628 #ifndef BEAN
00629       SmartRefVector<Event::McParticle> dref1=(*it)->daughterList();
00630 #else
00631       vector < int >dref1 = daughter->getDaughters ();
00632 #endif
00633       if(dref1.size()!=1){
00634 #ifndef BEAN
00635         log<< MSG::WARNING<<"unknown decay of K0, aborting"<<endreq;
00636 #else
00637         cout << "unknown decay of K0, aborting" << endl;
00638 #endif
00639         return 0;
00640       }
00641 #ifndef BEAN
00642       pdg=dref1[0]->particleProperty();
00643 #else
00644       pdg = m_TMcEvent->getMcParticle (dref1[0])->getParticleID ();
00645 #endif
00646     }
00647     if((abs(pdg)==22)&&m_ignorePhotons)continue;
00648     if((pdg==-22)&&m_ignoreFSR)continue;
00649     key.push_back(pdg);
00650   }
00651 
00652   sort(key.begin(),key.end());
00653   if(m_ignorePhotons&&(key.size()==0))key.push_back(22);
00654   decayModeTab::iterator ittab=dTab->find(key);
00655   if(ittab==dTab->end())return 0;
00656   return ittab->second;
00657 }

StatusCode EventTagSvc::initialize (  ) 

Definition at line 58 of file EventTagSvc.cxx.

References buildAntiPartTabs(), chainTrigParticles, Bes_Common::DEBUG, calibUtil::ERROR, Bes_Common::INFO, m_buildAntiTabs, m_decayTabsFile, m_ignorePhotons, m_pdtFile, m_userDecayTabsFile, msgSvc(), name2pdg(), pdg2name(), readDecayTabFile(), readPdtFile(), and userChainTrig.

00058                                   {
00059 #ifndef BEAN
00060   Service::initialize();
00061   MsgStream log(msgSvc(), name());
00062 
00063   setProperties();
00064   log << MSG::INFO << "EventTagSvc initialize()" << endreq;
00065   log << MSG::INFO << "         pdgFile="<<m_pdtFile<<endreq;
00066   log << MSG::INFO << "         decayCodesFile="<<m_decayTabsFile<<endreq;
00067   log << MSG::INFO << "         userDecayTabsFile="<<m_userDecayTabsFile
00068       <<endreq;
00069   log << MSG::INFO << "         buildAntiPartTable="<<m_buildAntiTabs<<endreq;
00070   log << MSG::INFO << "         Ignore Photons="<<m_ignorePhotons<<endreq;
00071   log << MSG::INFO << " Chain trigger particles:"<<endreq; 
00072   for(std::vector<string>::iterator it=userChainTrig.begin();
00073    it!=userChainTrig.end();it++){
00074     log << MSG::INFO<<"                         " <<(*it)<<endreq;
00075   }
00076 #else
00077    if( verbose ) {
00078       cout << "EventTagSvc initialize()" << endl;
00079       cout << "         pdgFile=" << m_pdtFile << endl;
00080       cout << "         decayCodesFile=" << m_decayTabsFile << endl;
00081       cout << "         userDecayTabsFile=" << m_userDecayTabsFile << endl;
00082       cout << "         buildAntiPartTable=" << m_buildAntiTabs << endl;
00083       cout << "         Ignore Photons=" << m_ignorePhotons << endl;
00084       cout << " Chain trigger particles:" << endl;
00085 
00086       for (std::vector < string >::iterator it = userChainTrig.begin ();
00087         it != userChainTrig.end (); it++) {
00088          cout << "                         " << (*it) << endl;
00089       }
00090    }
00091 #endif
00092 
00093   //  static const bool CREATEIFNOTTHERE(true);
00094   if(readPdtFile(m_pdtFile.c_str())){
00095 #ifndef BEAN
00096     log << MSG::ERROR<<"Can not read pdgFile "<< m_pdtFile<<endreq;
00097     return StatusCode::StatusCode::FAILURE;
00098 #else
00099     cerr << "Can not read pdgFile " << m_pdtFile << endl;
00100     return false;
00101 #endif
00102   }
00103 
00104   if(readDecayTabFile(m_decayTabsFile)){
00105 #ifndef BEAN
00106     log << MSG::ERROR<<"Can not read decayTabsFile "<< m_decayTabsFile<<endreq;
00107     return StatusCode::StatusCode::FAILURE;
00108 #else
00109     cerr << "Can not read decayTabsFile " << m_decayTabsFile << endl;
00110     return false;
00111 #endif
00112   }
00113 
00114   if(m_userDecayTabsFile.size()){
00115     if(readDecayTabFile(m_userDecayTabsFile)){
00116 #ifndef BEAN
00117       log << MSG::ERROR<<"Can not read userDecayTabsFile "<<m_userDecayTabsFile
00118           <<endreq;
00119       return StatusCode::StatusCode::FAILURE;
00120 #else
00121       cerr << "Can not read userDecayTabsFile " << m_userDecayTabsFile << endl;
00122       return false;
00123 #endif
00124     }
00125   }
00126 
00127   if(m_buildAntiTabs){
00128     if(buildAntiPartTabs()){
00129 #ifndef BEAN
00130       log << MSG::ERROR<<"fail to build decay code table for anti-particles"
00131           <<endreq;
00132       return StatusCode::StatusCode::FAILURE;
00133 #else
00134       cerr << "fail to build decay code table for anti-particles" << endl;
00135       return false;
00136 #endif
00137     }
00138   }
00139   
00140   // fill the set with trigger chain particles
00141   for(std::vector<string>::iterator it=userChainTrig.begin();
00142    it!=userChainTrig.end();it++){
00143     long int pdg=labs(name2pdg(*it));
00144     if(pdg==0){
00145 #ifndef BEAN
00146       log << MSG::ERROR<<"Unknown ChainTrigger particle "<< (*it)
00147           <<" ..ignoring"<<endreq;
00148 #else
00149       cerr << "Unknown ChainTrigger particle " << (*it) 
00150            <<  " ..ignoring" << endl;
00151 #endif
00152       continue;
00153     }
00154     chainTrigParticles.insert(pdg);
00155   }
00156 
00157 #ifndef BEAN
00158   log << MSG::DEBUG << "sorted chain trigger particles:"<<endreq; 
00159   for(set<long int>::iterator it=chainTrigParticles.begin();
00160    it!=chainTrigParticles.end();it++){
00161     log << MSG::DEBUG<<"                         "<<(*it)<<"  " 
00162         <<pdg2name(*it)<<endreq;
00163   }
00164 #else
00165    if (verbose) {
00166       cout << "sorted chain trigger particles:" << endl;
00167       for (set < long int >::iterator it = chainTrigParticles.begin ();
00168         it != chainTrigParticles.end (); it++) {
00169          cout << "                         " << (*it) << "  " 
00170               << pdg2name(*it) << endl;
00171       }
00172    }
00173 #endif
00174 
00175 
00176 #ifndef BEAN
00177   return StatusCode::SUCCESS;
00178 #else
00179   return true;
00180 #endif
00181 }

const InterfaceID & IEventTagSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 26 of file IEventTagSvc.h.

Referenced by queryInterface().

00026                                                      {
00027   static const InterfaceID _IID("IEventtagsvc", 1, 0);
00028   //  static const InterfaceID _IID(7091, 1, 0);
00029   return _IID;
00030 }

long int EventTagSvc::name2pdg ( std::string  pname  )  [virtual]

Implements IEventTagSvc.

Referenced by initialize().

string EventTagSvc::pdg2name ( long int  pdg  )  [virtual]

Implements IEventTagSvc.

Definition at line 207 of file EventTagSvc.cxx.

References pdg2nameTab, and deljobs::string.

Referenced by buildAntiPartTabs(), and initialize().

00207                                         {
00208   map<long int,string>::iterator it=pdg2nameTab.find(pdg);
00209   if(it!=pdg2nameTab.end())return it->second;
00210   return string("");
00211 }

StatusCode EventTagSvc::queryInterface ( const InterfaceID &  ,
void **  ppvInterface 
) [virtual]

Definition at line 192 of file EventTagSvc.cxx.

References IEventTagSvc::interfaceID().

00192                                                                         {
00193   if ( IEventTagSvc::interfaceID().versionMatch(riid) )    {
00194     *ppvInterface = (IEventTagSvc*)this;
00195   }
00196   else  {
00197     // Interface is not directly available: try out a base class
00198     return Service::queryInterface(riid, ppvInterface);
00199   }
00200   addRef();
00201   return StatusCode::SUCCESS;
00202 }

int EventTagSvc::readDecayTabFile ( std::string  fname  )  [private]

Referenced by initialize().

int EventTagSvc::readPdtFile ( std::string  fname  )  [private]

Referenced by initialize().


Member Data Documentation

std::set<long int> EventTagSvc::chainTrigParticles [private]

Definition at line 101 of file EventTagSvc.h.

Referenced by getChainCode(), and initialize().

bool EventTagSvc::m_buildAntiTabs [private]

Definition at line 92 of file EventTagSvc.h.

Referenced by EventTagSvc(), and initialize().

std::map<int,decayModeTab*> EventTagSvc::m_decayTabList [private]

Definition at line 98 of file EventTagSvc.h.

Referenced by buildAntiPartTabs(), and getDecayCode().

std::string EventTagSvc::m_decayTabsFile [private]

Definition at line 89 of file EventTagSvc.h.

Referenced by EventTagSvc(), and initialize().

bool EventTagSvc::m_digK0 [private]

Definition at line 95 of file EventTagSvc.h.

Referenced by EventTagSvc(), and getDecayCode().

bool EventTagSvc::m_ignoreFSR [private]

Definition at line 94 of file EventTagSvc.h.

Referenced by EventTagSvc(), and getDecayCode().

bool EventTagSvc::m_ignorePhotons [private]

Definition at line 93 of file EventTagSvc.h.

Referenced by EventTagSvc(), getCharmDecayType(), getDecayCode(), and initialize().

std::string EventTagSvc::m_pdtFile [private]

Definition at line 90 of file EventTagSvc.h.

Referenced by EventTagSvc(), and initialize().

std::string EventTagSvc::m_userDecayTabsFile [private]

Definition at line 91 of file EventTagSvc.h.

Referenced by EventTagSvc(), and initialize().

std::map<std::string,long int> EventTagSvc::name2pdgTab [private]

Definition at line 99 of file EventTagSvc.h.

std::map<long int,std::string> EventTagSvc::pdg2nameTab [private]

Definition at line 100 of file EventTagSvc.h.

Referenced by pdg2name().

std::vector<std::string> EventTagSvc::userChainTrig [private]

Definition at line 96 of file EventTagSvc.h.

Referenced by EventTagSvc(), and initialize().


Generated on Tue Nov 29 23:18:50 2016 for BOSS_7.0.2 by  doxygen 1.4.7