#include <EventTagSvc.h>
Inheritance diagram for EventTagSvc:
Public Member Functions | |
EventTagSvc (const std::string &name, ISvcLocator *svc) | |
EventTagSvc (const std::string &name, ISvcLocator *svc) | |
StatusCode | finalize () |
StatusCode | finalize () |
unsigned long long int | getChainCode (Event::McParticle *part) |
unsigned long long int | getChainCode (Event::McParticle *part) |
unsigned int | getCharmDecayType (Event::McParticle *part) |
unsigned int | getCharmDecayType (Event::McParticle *part) |
int | getDecayCode (Event::McParticle *part) |
int | getDecayCode (Event::McParticle *part) |
StatusCode | initialize () |
StatusCode | initialize () |
virtual long int | name2pdg (std::string pname)=0 |
long int | name2pdg (string pname) |
long int | name2pdg (string pname) |
string | pdg2name (long int pdg) |
string | pdg2name (long int pdg) |
virtual StatusCode | queryInterface (const InterfaceID &, void **ppvInterface) |
virtual StatusCode | queryInterface (const InterfaceID &, void **ppvInterface) |
Static Public Member Functions | |
const InterfaceID & | interfaceID () |
const InterfaceID & | interfaceID () |
Private Member Functions | |
int | buildAntiPartTabs () |
int | buildAntiPartTabs () |
int | readDecayTabFile (string fname) |
int | readDecayTabFile (string fname) |
int | readPdtFile (string fname) |
int | readPdtFile (string fname) |
Private Attributes | |
std::set< long int > | chainTrigParticles |
std::set< long int > | chainTrigParticles |
bool | m_buildAntiTabs |
std::map< int, decayModeTab * > | m_decayTabList |
std::map< int, decayModeTab * > | m_decayTabList |
string | m_decayTabsFile |
bool | m_digK0 |
bool | m_ignoreFSR |
bool | m_ignorePhotons |
string | m_pdtFile |
string | m_userDecayTabsFile |
std::map< string, long int > | name2pdgTab |
std::map< string, long int > | name2pdgTab |
std::map< long int, string > | pdg2nameTab |
std::map< long int, string > | pdg2nameTab |
std::vector< string > | userChainTrig |
std::vector< string > | userChainTrig |
|
00008 : 00009 Service(name,svc) 00010 { 00011 00012 declareProperty("pdgFile", m_pdtFile="pdt.table"); 00013 declareProperty("decayCodesFile", m_decayTabsFile="decay.codes"); 00014 // declareProperty("userDecayCodesFile", m_userDecayTabsFile="userdecay.codes"); 00015 declareProperty("userDecayCodesFile", m_userDecayTabsFile=""); 00016 declareProperty("buildAntiPartTable", m_buildAntiTabs=true); 00017 declareProperty("ignorePhotons", m_ignorePhotons=true); 00018 declareProperty("ignoreFSR", m_ignoreFSR=true); 00019 declareProperty("chainTrigParticles", userChainTrig); 00020 declareProperty("digK0", m_digK0=true); 00021 }
|
|
|
|
|
|
00360 { 00361 MsgStream log(msgSvc(), name()); 00362 decayModeTab* dTab; 00363 decayModeTab* adTab; 00364 keyVector key,akey; 00365 int mother,amother,code; 00366 for(std::map<int,decayModeTab*>::iterator itl=m_decayTabList.begin(); 00367 itl!=m_decayTabList.end();itl++){ 00368 mother=itl->first; 00369 amother=-mother; 00370 if(m_decayTabList.find(amother)!=m_decayTabList.end())continue ;// aparticle tab already exist 00371 if(pdg2name(mother).size()==0){ 00372 log<<MSG::ERROR<<" buildAntiPartTabs :: Unknown pdg code for mother particle "<<endreq; 00373 return 1; 00374 } 00375 if(pdg2name(amother).size()==0)continue; //Aparticle==particle?? 00376 log<<MSG::INFO<<" buildAntiPartTabs :: create new table for particle " 00377 << amother<<"("<<pdg2name(amother)<<")"<<endreq; 00378 dTab=itl->second; 00379 adTab=new decayModeTab; 00380 m_decayTabList[amother]=adTab; 00381 key.clear(); 00382 for(decayModeTab::iterator it=dTab->begin();it!=dTab->end();it++){ 00383 key=it->first; 00384 code=it->second; 00385 for(keyVector::iterator it=key.begin();it!=key.end();it++){ 00386 if(pdg2name(*it).size()==0){ 00387 log<<MSG::ERROR<<" buildAntiPartTabs :: Unknown pdg code" 00388 << "for particle in keyVector"<<endreq; 00389 return 1; 00390 } 00391 if(pdg2name(-(*it)).size()==0)continue ; // true neutral ?? 00392 (*it) *= -1; 00393 } 00394 sort(key.begin(),key.end()); 00395 (*adTab)[key]=code; 00396 } 00397 } 00398 return 0; 00399 }
|
|
|
|
00077 { 00078 // Part 1: Get the messaging service, print where you are 00079 MsgStream log(msgSvc(), name()); 00080 log << MSG::INFO << "EventTagSvc finalize()" << endreq; 00081 return StatusCode::SUCCESS; 00082 }
|
|
Implements IEventTagSvc. |
|
Implements IEventTagSvc. 00466 { 00467 unsigned long long int code=0; 00468 int shift=0; 00469 vector<Event::McParticle*> chainVect; 00470 while(shift<57){ 00471 code |= (getDecayCode(part)&0xFF)<<shift; 00472 SmartRefVector<Event::McParticle> dref=part->daughterList(); 00473 chainVect.clear(); 00474 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();it!=dref.end();it++){ 00475 int abspdg=abs((*it)->particleProperty()); 00476 if(((((abspdg%1000)/10)<45) && (((abspdg%1000)/10)>40)) // select particles with *4?? pdg code 00477 ||(chainTrigParticles.find(abspdg)!=chainTrigParticles.end())) { 00478 chainVect.push_back(*it); 00479 } 00480 } 00481 if(chainVect.size()==0 ||chainVect.size()>2)break; 00482 if(chainVect.size()==1){part=chainVect[0];} 00483 else{ 00484 sort(chainVect.begin(),chainVect.end(),mcPartPrtLess); 00485 code |= ((getDecayCode(chainVect[0])&0xFF)<<(shift+8)); 00486 code |= ((getDecayCode(chainVect[1])&0xFF)<<(shift+16)); 00487 break; 00488 } 00489 shift+=8; 00490 } 00491 return code; 00492 }
|
|
Implements IEventTagSvc. |
|
Implements IEventTagSvc. 00401 { 00402 unsigned int a=0; 00403 // int type=0; 00404 if(! part) return 0xF; 00405 SmartRefVector<Event::McParticle> dref=part->daughterList(); 00406 if(dref.size()==0) return 0; 00407 int nhad=0; 00408 long int pdg1=0; 00409 bool dd=false; 00410 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin(); it!=dref.end();it++){ 00411 int pdg=abs((*it)->particleProperty()); 00412 if((pdg==22)&&m_ignorePhotons)continue; 00413 if(pdg==22){a|=1;} 00414 else if( (pdg>10)&&(pdg<19) ){a |=(1<<1);} 00415 else if( pdg>110) { 00416 if( ((pdg%1000)/100==4)&&((pdg%100)/10==4)){ 00417 a |= 1<<3; 00418 } 00419 else{ 00420 a |= 1<<2; 00421 nhad+=1; 00422 if(nhad==1)pdg1=pdg; 00423 dd=(pdg1==pdg); 00424 } 00425 } 00426 else a |=1<<4; 00427 } 00428 if(a>0xF)return 0xf; //unknown particle 00429 if(a==4){ // hadronic 00430 if((nhad!=2)||(!dd))return 6; 00431 // long int pdg1=dref[0]->particleProperty(); 00432 // long int pdg2=dref[1]->particleProperty(); 00433 // if(abs(pdg1)!=abs(pdg2)) return 6; 00434 switch (abs(pdg1)){ 00435 case 411: 00436 return 7; 00437 break; 00438 case 421: 00439 return 8; 00440 break; 00441 case 413: 00442 return 9; 00443 break; 00444 case 423: 00445 return 10; 00446 break; 00447 case 431: 00448 return 11; 00449 break; 00450 case 433: 00451 return 12; 00452 break; 00453 default: 00454 return 6; 00455 break; 00456 } 00457 } 00458 if((a&0xE)==2)return 1; // leptonic 00459 if((a&0x6)==0x6)return 2; // semileptonic 00460 if((a&0xE)==0xC)return 4; // hadronic charmonium transition 00461 if((a&0xE)==0x8)return 3; // radiative charmonium transition !!use 0XE mask for correct work with "ignore photons" options; 00462 if((a&1)==1)return 5; // radiative 00463 return 0xf; //unknown 00464 }
|
|
Implements IEventTagSvc. |
|
Implements IEventTagSvc. 00328 { 00329 MsgStream log(msgSvc(), name()); 00330 keyVector key; 00331 long int mother_pdg=part->particleProperty(); 00332 map<int,decayModeTab*>::iterator itlist=m_decayTabList.find(mother_pdg); 00333 if(itlist==m_decayTabList.end())return 0; 00334 decayModeTab* dTab=itlist->second; 00335 SmartRefVector<Event::McParticle> dref=part->daughterList(); 00336 if(dref.size()==0)return 0; 00337 key.clear(); 00338 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();it!=dref.end();it++){ 00339 int pdg=(*it)->particleProperty(); 00340 if(m_digK0&&(abs(pdg)==311)){ 00341 SmartRefVector<Event::McParticle> dref1=(*it)->daughterList(); 00342 if(dref1.size()!=1){ 00343 log<< MSG::WARNING<<"unknown decay of K0, aborting"<<endreq; 00344 return 0; 00345 } 00346 pdg=dref1[0]->particleProperty(); 00347 } 00348 if((abs(pdg)==22)&&m_ignorePhotons)continue; 00349 if((pdg==-22)&&m_ignoreFSR)continue; 00350 key.push_back(pdg); 00351 } 00352 00353 sort(key.begin(),key.end()); 00354 if(m_ignorePhotons&&(key.size()==0))key.push_back(22); 00355 decayModeTab::iterator ittab=dTab->find(key); 00356 if(ittab==dTab->end())return 0; 00357 return ittab->second; 00358 }
|
|
|
|
00023 { 00024 Service::initialize(); 00025 MsgStream log(msgSvc(), name()); 00026 00027 setProperties(); 00028 log << MSG::INFO << "EventTagSvc initialize()" << endreq; 00029 log << MSG::INFO << " pdgFile="<<m_pdtFile<<endreq; 00030 log << MSG::INFO << " decayCodesFile="<<m_decayTabsFile<<endreq; 00031 log << MSG::INFO << " userDecayTabsFile="<<m_userDecayTabsFile<<endreq; 00032 log << MSG::INFO << " buildAntiPartTable="<<m_buildAntiTabs<<endreq; 00033 log << MSG::INFO << " Ignore Photons="<<m_ignorePhotons<<endreq; 00034 log << MSG::INFO << " Chain trigger particles:"<<endreq; 00035 for(std::vector<string>::iterator it=userChainTrig.begin();it!=userChainTrig.end();it++){ 00036 log << MSG::INFO<<" " <<(*it)<<endreq; 00037 } 00038 // static const bool CREATEIFNOTTHERE(true); 00039 if(readPdtFile(m_pdtFile.c_str())){ 00040 log << MSG::ERROR<<"Can not read pdgFile "<< m_pdtFile<<endreq; 00041 return StatusCode::StatusCode::FAILURE; 00042 } 00043 if(readDecayTabFile(m_decayTabsFile)){ 00044 log << MSG::ERROR<<"Can not read decayTabsFile "<< m_decayTabsFile<<endreq; 00045 return StatusCode::StatusCode::FAILURE; 00046 } 00047 if(m_userDecayTabsFile.size()){ 00048 if(readDecayTabFile(m_userDecayTabsFile)){ 00049 log << MSG::ERROR<<"Can not read userDecayTabsFile "<<m_userDecayTabsFile<<endreq; 00050 return StatusCode::StatusCode::FAILURE; 00051 } 00052 } 00053 if(m_buildAntiTabs){ 00054 if(buildAntiPartTabs()){ 00055 log << MSG::ERROR<<"fail to build decay code table for anti-particles"<<endreq; 00056 return StatusCode::StatusCode::FAILURE; 00057 } 00058 } 00059 // fill the set with trigger chain particles 00060 for(std::vector<string>::iterator it=userChainTrig.begin();it!=userChainTrig.end();it++){ 00061 long int pdg=abs(name2pdg(*it)); 00062 if(pdg==0){ 00063 log << MSG::ERROR<<"Unknown ChainTrigger particle "<< (*it)<<" ..ignoring"<<endreq; 00064 continue; 00065 } 00066 chainTrigParticles.insert(pdg); 00067 } 00068 log << MSG::DEBUG << "sorted chain trigger particles:"<<endreq; 00069 for(set<long int>::iterator it=chainTrigParticles.begin();it!=chainTrigParticles.end();it++){ 00070 log << MSG::DEBUG<<" "<<(*it)<<" " <<pdg2name(*it)<<endreq; 00071 } 00072 00073 00074 return StatusCode::SUCCESS; 00075 }
|
|
|
|
00026 { 00027 static const InterfaceID _IID("IEventtagsvc", 1, 0); 00028 // static const InterfaceID _IID(7091, 1, 0); 00029 return _IID; 00030 }
|
|
|
|
|
|
00104 { 00105 map<string,long int>::iterator it=name2pdgTab.find(pname); 00106 if(it!=name2pdgTab.end())return it->second; 00107 return 0; 00108 }
|
|
Implements IEventTagSvc. |
|
Implements IEventTagSvc. 00098 { 00099 map<long int,string>::iterator it=pdg2nameTab.find(pdg); 00100 if(it!=pdg2nameTab.end())return it->second; 00101 return string(""); 00102 }
|
|
|
|
00084 { 00085 if ( IEventTagSvc::interfaceID().versionMatch(riid) ) { 00086 *ppvInterface = (IEventTagSvc*)this; 00087 } 00088 else { 00089 // Interface is not directly available: try out a base class 00090 return Service::queryInterface(riid, ppvInterface); 00091 } 00092 addRef(); 00093 return StatusCode::SUCCESS; 00094 }
|
|
|
|
00170 { 00171 MsgStream log(msgSvc(), name()); 00172 ifstream infile; 00173 infile.open(fname.c_str()); 00174 if(!infile.is_open()){ 00175 log<<MSG::ERROR<< "Can not open decay table file :" <<fname<<endreq; 00176 infile.close(); 00177 return 1; 00178 } 00179 log<<MSG::INFO<<"Reading decay codes from file " << fname<<endreq; 00180 string ln; 00181 long int pdg,mo_pdg; 00182 int dcode; 00183 int nstr=0; 00184 char* pch; 00185 char str[256],mother[256]; 00186 char whitespaces[]=" \t\f\v\n\r"; 00187 while (! infile.eof() ){ 00188 getline (infile,ln); 00189 nstr++; 00190 if(ln.empty())continue; 00191 if(ln[0]=='#'||ln[0]=='*')continue; 00192 if(ln.size()>255){ 00193 log<<MSG::ERROR<<"line "<< nstr <<"in " 00194 <<fname<<" is too big" <<endreq; 00195 infile.close(); 00196 return 1; 00197 } 00198 strcpy(str,ln.c_str()); 00199 pch = strtok (str,whitespaces); 00200 if(pch==NULL)continue; 00201 if(strcmp(pch,"Decay")!=0){ 00202 log<<MSG::ERROR<<"No open decay, unrecognized token in line " 00203 <<nstr <<" of " <<fname<<endreq; 00204 infile.close(); 00205 return 1; 00206 } 00207 pch = strtok (NULL, whitespaces); 00208 if(pch==NULL) { 00209 log<<MSG::ERROR<< "Can not find particles in line " 00210 << nstr <<" of " <<fname<<endreq; 00211 infile.close(); 00212 return 1; 00213 } 00214 mo_pdg=name2pdg(string(pch)); 00215 strcpy(mother,pch); 00216 if(mo_pdg==0){ 00217 log<<MSG::ERROR<< "Unrecognized particle "<<pch<<" in line " << nstr 00218 <<" of " <<fname<<endreq; 00219 infile.close(); 00220 return 1; 00221 } 00222 log<<MSG::INFO<<"START DECAY TABLE FOR " << mother<<", pdg_code:"<<mo_pdg<<endl; 00223 00224 decayModeTab* dTab; 00225 map<int,decayModeTab*>::iterator itlist=m_decayTabList.find(mo_pdg); 00226 if(itlist!=m_decayTabList.end()){ 00227 log<<MSG::WARNING<< "add new info into existing decay tab for "<<mother<<endreq; 00228 dTab=itlist->second; 00229 } 00230 else{ 00231 log<<MSG::INFO<< "Create new decay code table for "<<mother<<endreq; 00232 dTab=new decayModeTab; 00233 m_decayTabList[mo_pdg]=dTab; 00234 } 00235 00236 while(true){ 00237 getline (infile,ln); 00238 if( infile.eof() ){ 00239 log<<MSG::ERROR << "Enexpected EOF for dacay code file " 00240 <<fname <<endreq; 00241 infile.close(); 00242 return 1; 00243 } 00244 nstr++; 00245 if(ln.empty())continue; 00246 if(ln[0]=='#')continue; 00247 if(ln.size()>255){ 00248 log<<MSG::ERROR<<"line "<< nstr <<"in decay table file " 00249 <<fname<<" is too big" <<endreq; 00250 infile.close(); 00251 return 1; 00252 } 00253 strcpy(str,ln.c_str()); 00254 pch = strtok (str,whitespaces); 00255 if(pch==NULL)continue; 00256 if(strcmp(pch,"Enddecay")==0){ 00257 log<<MSG::INFO <<" End of "<< mother <<" decay table" <<endreq; 00258 break; 00259 } 00260 log<<MSG::DEBUG<<"parsing line "<<ln<<endreq; 00261 dcode=atoi(pch); 00262 if(dcode<=0||dcode>255){ 00263 log<<MSG::ERROR<< " wrong decay code in line "<<nstr 00264 <<", file "<<fname<< endreq; 00265 infile.close(); 00266 return 1; 00267 } 00268 // decayModeTab::iterator itTab=dTab->find(code); 00269 //if( itTab != dTab->end()){ 00270 00271 log<<MSG::DEBUG<<" dcode:"<<dcode<<", particles: "; 00272 pch = strtok (NULL, whitespaces); 00273 if(pch==NULL){ 00274 // if( 00275 log<<MSG::ERROR<< " no decay found in line "<<nstr 00276 <<", file "<<fname<< endreq; 00277 infile.close(); 00278 return 1; 00279 } 00280 // keyVector* pKey=new keyVector; 00281 keyVector key; 00282 key.clear(); 00283 // keyVector* pKey=&key; 00284 while (pch != NULL){ 00285 log<<MSG::DEBUG <<pch<<" "; 00286 pdg=name2pdg(string(pch)); 00287 if(pdg==0){ 00288 log<<MSG::ERROR<<endl<< "Unrecognized particle " <<pch <<" in line " << nstr 00289 <<" of " <<fname<<endreq; 00290 infile.close(); 00291 return 1; 00292 } 00293 // pKey->push_back(pdg); 00294 key.push_back(pdg); 00295 pch = strtok (NULL, whitespaces); 00296 } 00297 00298 // sort(pKey->begin(),pKey->end()); 00299 sort(key.begin(),key.end()); 00300 log<<MSG::DEBUG<<" sorted pdg" ; 00301 // for(keyVector::iterator it=pKey->begin(); it!=pKey->end(); it++) 00302 for(keyVector::iterator it=key.begin(); it!=key.end(); it++) 00303 log<<MSG::DEBUG <<" "<<(*it); 00304 log<<MSG::DEBUG<<endreq; 00305 // decayModeTab::iterator itdec=dTab->find(*pKey); 00306 decayModeTab::iterator itdec=dTab->find(key); 00307 if(itdec!=dTab->end()){ 00308 if(itdec->second !=dcode){ 00309 log<<MSG::ERROR << "line "<<nstr<<" of file " <<fname<<"has an error : "<<endreq ; 00310 log<<MSG::ERROR<<"decay of "<<mother<< " to"; 00311 // for(keyVector::iterator it=pKey->begin(); it!=pKey->end(); it++) 00312 for(keyVector::iterator it=key.begin(); it!=key.end(); it++) 00313 log<<MSG::ERROR<<" "<<pdg2name(*it); 00314 log<<MSG::ERROR<<" is already in table. Aborting."<<endreq; 00315 log<<MSG::ERROR<<"check line "<<nstr<<" of " <<fname<<endreq; 00316 infile.close(); 00317 return 1; 00318 } 00319 } 00320 // (*dTab)[*pKey]=dcode; 00321 (*dTab)[key]=dcode; 00322 } 00323 } // end if file read loop 00324 infile.close(); 00325 return 0; 00326 }
|
|
|
|
00111 { 00112 MsgStream log(msgSvc(), name()); 00113 ifstream infile; 00114 infile.open(fname.c_str()); 00115 if(!infile.is_open()){ 00116 log<<MSG::ERROR<< "Can not open pdg-code file :" <<fname<<endreq; 00117 return 1; 00118 } 00119 log<<MSG::INFO<<"reading pdg codes table from "<<fname<<endreq; 00120 string ln; 00121 int nstr=0; 00122 long int pcode; 00123 string cmd,dummy,pname,pcode_str; 00124 stringstream* lns; 00125 while (! infile.eof() ){ 00126 getline (infile,ln); 00127 nstr++; 00128 log<<MSG::DEBUG<<"parsing line:"<<ln<<endreq; 00129 if(ln.empty())continue; 00130 if(ln[0]=='*')continue; 00131 lns=new stringstream; 00132 (*lns)<<ln; 00133 cmd=""; 00134 (*lns)>>cmd; 00135 if(!strcmp(cmd.c_str(),"add")){ 00136 pcode=0; 00137 pname=""; 00138 pcode_str=""; 00139 (*lns)>>dummy>>dummy>>pname>>pcode_str; 00140 pcode=atol(pcode_str.c_str()); 00141 if(pcode==0||pcode==LONG_MAX||pcode==LONG_MIN){ 00142 log<<MSG::ERROR<<"Unrecognized particle code in line " 00143 <<nstr<<" of file" <<fname<<endreq; 00144 infile.close(); 00145 return 1; 00146 } 00147 log<<MSG::DEBUG<<" find particle: " <<pname<<" pgd:"<<pcode <<endreq; 00148 if(pdg2nameTab.find(pcode)!=pdg2nameTab.end()){ 00149 log<<MSG::ERROR<< "pdg code "<<pcode 00150 <<" is repeated in line "<<nstr<<". Aborting"<<endreq; 00151 infile.close(); 00152 return 1; 00153 } 00154 if(name2pdgTab.find(pname)!=name2pdgTab.end()){ 00155 log<<MSG::ERROR<< "particle name "<<pcode 00156 <<" is repeated in line "<<nstr<<". Aborting"<<endreq; 00157 infile.close(); 00158 return 1; 00159 } 00160 pdg2nameTab[pcode]=pname; 00161 name2pdgTab[pname]=pcode; 00162 } 00163 delete lns; 00164 } 00165 infile.close(); 00166 return 0; 00167 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|