BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
EventTagSvc Class Reference

#include <EventTagSvc.h>

+ Inheritance diagram for EventTagSvc:

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)
 

Detailed Description

Definition at line 26 of file EventTagSvc.h.

Constructor & Destructor Documentation

◆ EventTagSvc()

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

Definition at line 24 of file EventTagSvc.cxx.

24 :
25 base_class(name,svc)
26{
27
28 declareProperty("pdgFile", m_pdtFile="pdt.table");
29 declareProperty("decayCodesFile", m_decayTabsFile="decay.codes");
30 // declareProperty("userDecayCodesFile",
31 // m_userDecayTabsFile="userdecay.codes");
32 declareProperty("userDecayCodesFile", m_userDecayTabsFile="");
33 declareProperty("buildAntiPartTable", m_buildAntiTabs=true);
34 declareProperty("ignorePhotons", m_ignorePhotons=true);
35 declareProperty("ignoreFSR", m_ignoreFSR=true);
36 declareProperty("chainTrigParticles", userChainTrig);
37 declareProperty("digK0", m_digK0=true);
38}

Member Function Documentation

◆ finalize()

StatusCode EventTagSvc::finalize ( )

Definition at line 186 of file EventTagSvc.cxx.

186 {
187 // Part 1: Get the messaging service, print where you are
188 MsgStream log(msgSvc(), name());
189 log << MSG::INFO << "EventTagSvc finalize()" << endreq;
190 return StatusCode::SUCCESS;
191}
IMessageSvc * msgSvc()

◆ getChainCode()

unsigned long long int EventTagSvc::getChainCode ( Event::McParticle * part)

Definition at line 809 of file EventTagSvc.cxx.

809 {
810#else
811unsigned long long int EventTagSvc::getChainCode (TMcParticle * part){
812 if (!m_TMcEvent) {
813 cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
814 return -1;
815 }
816#endif
817 unsigned long long int code=0;
818 int shift=0;
819#ifndef BEAN
820 vector<Event::McParticle*> chainVect;
821#else
822 vector < TMcParticle * >chainVect;
823#endif
824 while(shift<57){
825 code |= (getDecayCode(part)&0xFF)<<shift;
826#ifndef BEAN
827 SmartRefVector<Event::McParticle> dref=part->daughterList();
828#else
829 vector < int >dref = part->getDaughters ();
830#endif
831 chainVect.clear();
832#ifndef BEAN
833 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();
834 it!=dref.end();it++){
835 int abspdg=abs((*it)->particleProperty());
836#else
837 for (unsigned int i = 0; i < dref.size (); i++) {
838 const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
839
840 int abspdg = abs (daughter->getParticleID ());
841#endif
842 if(((((abspdg%1000)/10)<45) && (((abspdg%1000)/10)>40)) // select particles with *4?? pdg code
843 ||(chainTrigParticles.find(abspdg)!=chainTrigParticles.end())) {
844#ifndef BEAN
845 chainVect.push_back(*it);
846#else
847 chainVect.push_back (const_cast < TMcParticle * >(daughter));
848#endif
849 }
850 }
851 if(chainVect.size()==0 ||chainVect.size()>2)break;
852 if(chainVect.size()==1){part=chainVect[0];}
853 else{
854 sort(chainVect.begin(),chainVect.end(),mcPartPrtLess);
855 code |= ((getDecayCode(chainVect[0])&0xFF)<<(shift+8));
856 code |= ((getDecayCode(chainVect[1])&0xFF)<<(shift+16));
857 break;
858 }
859 shift+=8;
860 }
861 return code;
862}
bool mcPartPrtLess(Event::McParticle *p1, Event::McParticle *p2)
int getDecayCode(Event::McParticle *part)
unsigned long long int getChainCode(Event::McParticle *part)
Int_t getParticleID() const
Definition TMcParticle.h:17
vector< Int_t > getDaughters() const
Definition TMcParticle.h:85

Referenced by getChainCode().

◆ getCharmDecayType()

unsigned int EventTagSvc::getCharmDecayType ( Event::McParticle * part)

Definition at line 723 of file EventTagSvc.cxx.

723 {
724#else
725unsigned int EventTagSvc::getCharmDecayType (TMcParticle * part){
726 if (!m_TMcEvent) {
727 cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
728 return -1;
729 }
730#endif
731 unsigned int a=0;
732 // int type=0;
733 if(! part) return 0xF;
734#ifndef BEAN
735 SmartRefVector<Event::McParticle> dref=part->daughterList();
736#else
737 vector < int >dref = part->getDaughters ();
738#endif
739 if(dref.size()==0) return 0;
740 int nhad=0;
741 long int pdg1=0;
742 bool dd=false;
743#ifndef BEAN
744 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();
745 it!=dref.end();it++){
746 int pdg=abs((*it)->particleProperty());
747#else
748 for (unsigned int i = 0; i < dref.size (); i++) {
749 const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
750
751 int pdg = abs (daughter->getParticleID ());
752#endif
753 if((pdg==22)&&m_ignorePhotons)continue;
754 if(pdg==22){a|=1;}
755 else if( (pdg>10)&&(pdg<19) ){a |=(1<<1);}
756 else if( pdg>110) {
757 if( ((pdg%1000)/100==4)&&((pdg%100)/10==4)){
758 a |= 1<<3;
759 }
760 else{
761 a |= 1<<2;
762 nhad+=1;
763 if(nhad==1)pdg1=pdg;
764 dd=(pdg1==pdg);
765 }
766 }
767 else a |=1<<4;
768 }
769 if(a>0xF)return 0xf; //unknown particle
770 if(a==4){ // hadronic
771 if((nhad!=2)||(!dd))return 6;
772 // long int pdg1=dref[0]->particleProperty();
773 // long int pdg2=dref[1]->particleProperty();
774 // if(abs(pdg1)!=abs(pdg2)) return 6;
775 switch (abs(pdg1)){
776 case 411:
777 return 7;
778 break;
779 case 421:
780 return 8;
781 break;
782 case 413:
783 return 9;
784 break;
785 case 423:
786 return 10;
787 break;
788 case 431:
789 return 11;
790 break;
791 case 433:
792 return 12;
793 break;
794 default:
795 return 6;
796 break;
797 }
798 }
799 if((a&0xE)==2)return 1; // leptonic
800 if((a&0x6)==0x6)return 2; // semileptonic
801 if((a&0xE)==0xC)return 4; // hadronic charmonium transition
802 if((a&0xE)==0x8)return 3; // radiative charmonium transition !!use 0XE mask for correct work with "ignore photons" options;
803 if((a&1)==1)return 5; // radiative
804 return 0xf; //unknown
805}
unsigned int getCharmDecayType(Event::McParticle *part)

Referenced by getChainCode(), and getCharmDecayType().

◆ getDecayCode()

int EventTagSvc::getDecayCode ( Event::McParticle * part)

Definition at line 590 of file EventTagSvc.cxx.

590 {
591 MsgStream log(msgSvc(), name());
592#else
594 if (!m_TMcEvent) {
595 cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
596 return -1;
597 }
598#endif
600
601#ifndef BEAN
602 long int mother_pdg=part->particleProperty();
603#else
604 long int mother_pdg = part->getParticleID ();
605#endif
606
607 map<int,decayModeTab*>::iterator itlist=m_decayTabList.find(mother_pdg);
608 if(itlist==m_decayTabList.end())return 0;
609 decayModeTab* dTab=itlist->second;
610
611#ifndef BEAN
612 SmartRefVector<Event::McParticle> dref=part->daughterList();
613#else
614 vector < int >dref = part->getDaughters ();
615#endif
616 if(dref.size()==0)return 0;
617 key.clear();
618
619#ifndef BEAN
620 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();
621 it!=dref.end();it++){
622 int pdg=(*it)->particleProperty();
623#else
624 for (unsigned int i = 0; i < dref.size (); i++) {
625 const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
626
627 int pdg = daughter->getParticleID ();
628#endif
629 if(m_digK0&&(abs(pdg)==311)){
630#ifndef BEAN
631 SmartRefVector<Event::McParticle> dref1=(*it)->daughterList();
632#else
633 vector < int >dref1 = daughter->getDaughters ();
634#endif
635 if(dref1.size()!=1){
636#ifndef BEAN
637 log<< MSG::WARNING<<"unknown decay of K0, aborting"<<endreq;
638#else
639 cout << "unknown decay of K0, aborting" << endl;
640#endif
641 return 0;
642 }
643#ifndef BEAN
644 pdg=dref1[0]->particleProperty();
645#else
646 pdg = m_TMcEvent->getMcParticle (dref1[0])->getParticleID ();
647#endif
648 }
649 if((abs(pdg)==22)&&m_ignorePhotons)continue;
650 if((pdg==-22)&&m_ignoreFSR)continue;
651 key.push_back(pdg);
652 }
653
654 sort(key.begin(),key.end());
655 if(m_ignorePhotons&&(key.size()==0))key.push_back(22);
656 decayModeTab::iterator ittab=dTab->find(key);
657 if(ittab==dTab->end())return 0;
658 return ittab->second;
659}
std::vector< int > keyVector
Definition EventTagSvc.h:21
std::map< keyVector, int > decayModeTab
Definition EventTagSvc.h:22
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42

Referenced by getChainCode(), and getDecayCode().

◆ initialize()

StatusCode EventTagSvc::initialize ( )

Definition at line 60 of file EventTagSvc.cxx.

60 {
61#ifndef BEAN
62 Service::initialize();
63 MsgStream log(msgSvc(), name());
64
65 setProperties();
66 log << MSG::INFO << "EventTagSvc initialize()" << endreq;
67 log << MSG::INFO << " pdgFile="<<m_pdtFile<<endreq;
68 log << MSG::INFO << " decayCodesFile="<<m_decayTabsFile<<endreq;
69 log << MSG::INFO << " userDecayTabsFile="<<m_userDecayTabsFile
70 <<endreq;
71 log << MSG::INFO << " buildAntiPartTable="<<m_buildAntiTabs<<endreq;
72 log << MSG::INFO << " Ignore Photons="<<m_ignorePhotons<<endreq;
73 log << MSG::INFO << " Chain trigger particles:"<<endreq;
74 for(std::vector<string>::iterator it=userChainTrig.begin();
75 it!=userChainTrig.end();it++){
76 log << MSG::INFO<<" " <<(*it)<<endreq;
77 }
78#else
79 if( verbose ) {
80 cout << "EventTagSvc initialize()" << endl;
81 cout << " pdgFile=" << m_pdtFile << endl;
82 cout << " decayCodesFile=" << m_decayTabsFile << endl;
83 cout << " userDecayTabsFile=" << m_userDecayTabsFile << endl;
84 cout << " buildAntiPartTable=" << m_buildAntiTabs << endl;
85 cout << " Ignore Photons=" << m_ignorePhotons << endl;
86 cout << " Chain trigger particles:" << endl;
87
88 for (std::vector < string >::iterator it = userChainTrig.begin ();
89 it != userChainTrig.end (); it++) {
90 cout << " " << (*it) << endl;
91 }
92 }
93#endif
94
95 // static const bool CREATEIFNOTTHERE(true);
96 if(readPdtFile(m_pdtFile.c_str())){
97#ifndef BEAN
98 log << MSG::ERROR<<"Can not read pdgFile "<< m_pdtFile<<endreq;
99 return StatusCode::StatusCode::FAILURE;
100#else
101 cerr << "Can not read pdgFile " << m_pdtFile << endl;
102 return false;
103#endif
104 }
105
106 if(readDecayTabFile(m_decayTabsFile)){
107#ifndef BEAN
108 log << MSG::ERROR<<"Can not read decayTabsFile "<< m_decayTabsFile<<endreq;
109 return StatusCode::StatusCode::FAILURE;
110#else
111 cerr << "Can not read decayTabsFile " << m_decayTabsFile << endl;
112 return false;
113#endif
114 }
115
116 if(m_userDecayTabsFile.size()){
117 if(readDecayTabFile(m_userDecayTabsFile)){
118#ifndef BEAN
119 log << MSG::ERROR<<"Can not read userDecayTabsFile "<<m_userDecayTabsFile
120 <<endreq;
121 return StatusCode::StatusCode::FAILURE;
122#else
123 cerr << "Can not read userDecayTabsFile " << m_userDecayTabsFile << endl;
124 return false;
125#endif
126 }
127 }
128
129 if(m_buildAntiTabs){
130 if(buildAntiPartTabs()){
131#ifndef BEAN
132 log << MSG::ERROR<<"fail to build decay code table for anti-particles"
133 <<endreq;
134 return StatusCode::StatusCode::FAILURE;
135#else
136 cerr << "fail to build decay code table for anti-particles" << endl;
137 return false;
138#endif
139 }
140 }
141
142 // fill the set with trigger chain particles
143 for(std::vector<string>::iterator it=userChainTrig.begin();
144 it!=userChainTrig.end();it++){
145 long int pdg=labs(name2pdg(*it));
146 if(pdg==0){
147#ifndef BEAN
148 log << MSG::ERROR<<"Unknown ChainTrigger particle "<< (*it)
149 <<" ..ignoring"<<endreq;
150#else
151 cerr << "Unknown ChainTrigger particle " << (*it)
152 << " ..ignoring" << endl;
153#endif
154 continue;
155 }
156 chainTrigParticles.insert(pdg);
157 }
158
159#ifndef BEAN
160 log << MSG::DEBUG << "sorted chain trigger particles:"<<endreq;
161 for(set<long int>::iterator it=chainTrigParticles.begin();
162 it!=chainTrigParticles.end();it++){
163 log << MSG::DEBUG<<" "<<(*it)<<" "
164 <<pdg2name(*it)<<endreq;
165 }
166#else
167 if (verbose) {
168 cout << "sorted chain trigger particles:" << endl;
169 for (set < long int >::iterator it = chainTrigParticles.begin ();
170 it != chainTrigParticles.end (); it++) {
171 cout << " " << (*it) << " "
172 << pdg2name(*it) << endl;
173 }
174 }
175#endif
176
177
178#ifndef BEAN
179 return StatusCode::SUCCESS;
180#else
181 return true;
182#endif
183}
std::string pdg2name(long int pdg)
long int name2pdg(std::string pname)

◆ name2pdg()

long int EventTagSvc::name2pdg ( std::string pname)

Definition at line 214 of file EventTagSvc.cxx.

214 {
215 map<string,long int>::iterator it=name2pdgTab.find(pname);
216 if(it!=name2pdgTab.end())return it->second;
217 return 0;
218}

Referenced by initialize().

◆ pdg2name()

string EventTagSvc::pdg2name ( long int pdg)

Definition at line 208 of file EventTagSvc.cxx.

208 {
209 map<long int,string>::iterator it=pdg2nameTab.find(pdg);
210 if(it!=pdg2nameTab.end())return it->second;
211 return string("");
212}

Referenced by getDecayCode(), and initialize().


The documentation for this class was generated from the following files: