BOSS 7.0.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)
 
virtual StatusCode queryInterface (const InterfaceID &, void **ppvInterface)
 
 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)
 
- Public Member Functions inherited from IEventTagSvc
virtual int getDecayCode (Event::McParticle *part)=0
 
virtual unsigned long long int getChainCode (Event::McParticle *part)=0
 
virtual unsigned int getCharmDecayType (Event::McParticle *part)=0
 
virtual std::string pdg2name (long int pdg)=0
 
virtual long int name2pdg (std::string pname)=0
 
virtual ~IEventTagSvc ()
 
virtual int getDecayCode (Event::McParticle *part)=0
 
virtual unsigned long long int getChainCode (Event::McParticle *part)=0
 
virtual unsigned int getCharmDecayType (Event::McParticle *part)=0
 
virtual std::string pdg2name (long int pdg)=0
 
virtual long int name2pdg (std::string pname)=0
 
virtual ~IEventTagSvc ()
 

Additional Inherited Members

- Static Public Member Functions inherited from IEventTagSvc
static const InterfaceID & interfaceID ()
 
static const InterfaceID & interfaceID ()
 

Detailed Description

Constructor & Destructor Documentation

◆ EventTagSvc() [1/2]

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

Definition at line 22 of file EventTagSvc.cxx.

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

◆ EventTagSvc() [2/2]

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

Member Function Documentation

◆ finalize() [1/2]

StatusCode EventTagSvc::finalize ( )

Definition at line 184 of file EventTagSvc.cxx.

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

◆ finalize() [2/2]

StatusCode EventTagSvc::finalize ( )

◆ getChainCode() [1/2]

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

Implements IEventTagSvc.

Definition at line 807 of file EventTagSvc.cxx.

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

Referenced by getChainCode().

◆ getChainCode() [2/2]

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

Implements IEventTagSvc.

◆ getCharmDecayType() [1/2]

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

Implements IEventTagSvc.

Definition at line 721 of file EventTagSvc.cxx.

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

Referenced by getChainCode(), and getCharmDecayType().

◆ getCharmDecayType() [2/2]

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

Implements IEventTagSvc.

◆ getDecayCode() [1/2]

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

Implements IEventTagSvc.

Definition at line 588 of file EventTagSvc.cxx.

588 {
589 MsgStream log(msgSvc(), name());
590#else
592 if (!m_TMcEvent) {
593 cerr << "(ERROR) EventTag: you must set TMcEvent first!" << endl;
594 return -1;
595 }
596#endif
598
599#ifndef BEAN
600 long int mother_pdg=part->particleProperty();
601#else
602 long int mother_pdg = part->getParticleID ();
603#endif
604
605 map<int,decayModeTab*>::iterator itlist=m_decayTabList.find(mother_pdg);
606 if(itlist==m_decayTabList.end())return 0;
607 decayModeTab* dTab=itlist->second;
608
609#ifndef BEAN
610 SmartRefVector<Event::McParticle> dref=part->daughterList();
611#else
612 vector < int >dref = part->getDaughters ();
613#endif
614 if(dref.size()==0)return 0;
615 key.clear();
616
617#ifndef BEAN
618 for(SmartRefVector<Event::McParticle>::iterator it=dref.begin();
619 it!=dref.end();it++){
620 int pdg=(*it)->particleProperty();
621#else
622 for (unsigned int i = 0; i < dref.size (); i++) {
623 const TMcParticle *daughter = m_TMcEvent->getMcParticle (dref[i]);
624
625 int pdg = daughter->getParticleID ();
626#endif
627 if(m_digK0&&(abs(pdg)==311)){
628#ifndef BEAN
629 SmartRefVector<Event::McParticle> dref1=(*it)->daughterList();
630#else
631 vector < int >dref1 = daughter->getDaughters ();
632#endif
633 if(dref1.size()!=1){
634#ifndef BEAN
635 log<< MSG::WARNING<<"unknown decay of K0, aborting"<<endreq;
636#else
637 cout << "unknown decay of K0, aborting" << endl;
638#endif
639 return 0;
640 }
641#ifndef BEAN
642 pdg=dref1[0]->particleProperty();
643#else
644 pdg = m_TMcEvent->getMcParticle (dref1[0])->getParticleID ();
645#endif
646 }
647 if((abs(pdg)==22)&&m_ignorePhotons)continue;
648 if((pdg==-22)&&m_ignoreFSR)continue;
649 key.push_back(pdg);
650 }
651
652 sort(key.begin(),key.end());
653 if(m_ignorePhotons&&(key.size()==0))key.push_back(22);
654 decayModeTab::iterator ittab=dTab->find(key);
655 if(ittab==dTab->end())return 0;
656 return ittab->second;
657}
std::map< keyVector, int > decayModeTab
*************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().

◆ getDecayCode() [2/2]

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

Implements IEventTagSvc.

◆ initialize() [1/2]

StatusCode EventTagSvc::initialize ( )

Definition at line 58 of file EventTagSvc.cxx.

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

◆ initialize() [2/2]

StatusCode EventTagSvc::initialize ( )

◆ name2pdg() [1/2]

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

Implements IEventTagSvc.

Referenced by initialize().

◆ name2pdg() [2/2]

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

Implements IEventTagSvc.

◆ pdg2name() [1/2]

string EventTagSvc::pdg2name ( long int  pdg)
virtual

Implements IEventTagSvc.

Definition at line 207 of file EventTagSvc.cxx.

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

Referenced by getDecayCode(), and initialize().

◆ pdg2name() [2/2]

std::string EventTagSvc::pdg2name ( long int  pdg)
virtual

Implements IEventTagSvc.

◆ queryInterface() [1/2]

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

Definition at line 192 of file EventTagSvc.cxx.

192 {
193 if ( IEventTagSvc::interfaceID().versionMatch(riid) ) {
194 *ppvInterface = (IEventTagSvc*)this;
195 }
196 else {
197 // Interface is not directly available: try out a base class
198 return Service::queryInterface(riid, ppvInterface);
199 }
200 addRef();
201 return StatusCode::SUCCESS;
202}

◆ queryInterface() [2/2]

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

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