BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
EventFilter.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2//#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/SmartDataPtr.h"
4//#include "GaudiKernel/PropertyMgr.h"
5#include "EventModel/Event.h"
7#include "Identifier/HltID.h"
8#include "HltEvent/HltInf.h"
10#include "TrigEvent/TrigData.h"
12
13long unsigned EventFilter::m_nTotalEvent =0;
14long unsigned EventFilter::m_npass =0;
15bool EventFilter::m_efResult = false;
16std::string EventFilter::m_type ;
17
18DECLARE_COMPONENT(EventFilter)
19EventFilter::EventFilter(const std::string& name, ISvcLocator* pSvcLocator) :
20 Algorithm(name, pSvcLocator) {
21
22 declareProperty("useTrigger", m_trgFlag =true);
23 declareProperty("OutputLevel", m_outputLevel = MSG::NIL);
24 declareProperty("OpenedChannels", m_chn );
25 declareProperty("Example", m_example = false);
26
27}
28
31
33
34 MsgStream log(msgSvc(), name());
35 log << MSG::INFO << "in initialize()" << endreq;
36
37 m_nTotalEvent =0;
38 m_npass =0;
39 m_efResult = false;
40 m_type = "RefuseByEF";
41
42 return StatusCode::SUCCESS;
43}
44
45
47
48 MsgStream log(msgSvc(), name());
49
50 uint32_t run=0,event=0;
51 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
52 if (!eventHeader) {
53 log << MSG::FATAL << "Could not find Event Header" << endreq;
54 return( StatusCode::FAILURE);
55 }
56 run=eventHeader->runNumber();
57 event=eventHeader->eventNumber();
58 log << MSG::INFO << "execute() RunNo=" << run << ", EventNo=" << event << endreq;
59
60 m_nTotalEvent++;
61
62 m_efResult = false;
63 setFilterPassed(false);
64 m_type = "RefuseByEF";
65
66 if(m_trgFlag){
67 SmartDataPtr<TrigData> trg(eventSvc(),"/Event/Trig/TrigData");
68 if(!trg) {
69 log << MSG::WARNING << "Could not find Event TrigData" << endreq;
70 }
71 else {
72 bool pass=false;
73 for(int i=0;i<16;i++){
74 if(trg->getTrigChannel(i)) pass=true;
75 }
76 if(!pass) {
77 m_efResult = false;
78 m_type = "RefuseByTrg";
79 return( StatusCode::SUCCESS);
80 }
81 }
82 }
83
84 DstHltInf* aHlt;
85 SmartDataPtr<HltInf> hlt(eventSvc(),"/Event/Hlt/HltInf");
86 if(!hlt) {
87 log << MSG::WARNING << "Could not find Event HltInf (try DstHltInf now)" << endreq;
88 SmartDataPtr<DstHltInf> hltDst(eventSvc(),"/Event/Hlt/DstHltInf");
89 if(!hltDst){
90 log << MSG::FATAL << "Could not find Event DstHltInf too ( please re-generate data)" << endreq;
91 return( StatusCode::FAILURE);
92 //return( StatusCode::SUCCESS);
93 }
94 else{
95 aHlt=hltDst;
96 }
97 }
98 else aHlt=hlt;
99
100 std::vector<std::string>::iterator it=m_chn.begin();
101 m_type = aHlt->getEventName();
102 if(aHlt->getEventType()==0) {
103 log << MSG::WARNING << m_type << endreq;
104 }
105 if(log.level()<=MSG::VERBOSE) aHlt->print();
106
107 for(;it!=m_chn.end();it++){
108 if(aHlt->isType(*it)) {
109 m_efResult=true;
110 setFilterPassed(true);
111 m_npass++;
112 log << MSG::INFO << "this event is passed" << endreq;
113 break;
114 }
115 }
116 log << MSG::INFO << "this event is a " << m_type <<endreq;
117
118 if(m_example&&!hlt) {
119 cout<< "****** Example for getting event filter informatiom ******" << endl;
120 cout<< "****** Please refer to the code in EventFilter.cxx ******" << endl;
121 print(hlt);
122 }
123
124 return ( StatusCode::SUCCESS);
125}
126
128 int nmdc,ntof,nemc,nmuc,ntrk,nshower;
129 float etot,e1,e2,cose1,cose2,p1,p2,acop,acole,acol;
130 if(ahlt->getData(Identifier(HltID::NMDC),(uint32_t*)&nmdc)) cout<< "nmdc=" << nmdc <<endl;
131 if(ahlt->getData(Identifier(HltID::NTOF),(uint32_t*)&ntof)) cout<< "ntof=" << ntof <<endl;
132 if(ahlt->getData(Identifier(HltID::NEMC),(uint32_t*)&nemc)) cout<< "nemc=" << nemc <<endl;
133 if(ahlt->getData(Identifier(HltID::NMUC),(uint32_t*)&nmuc)) cout<< "nmuc=" << nmuc <<endl;
134 if(ahlt->getData(Identifier(HltID::NTRK),(uint32_t*)&ntrk)) cout<< "ntrk=" << ntrk <<endl;
135 if(ahlt->getData(Identifier(HltID::NSHW),(uint32_t*)&nshower)) cout<< "nshower=" << nshower <<endl;
136 if(ahlt->getData(Identifier(HltID::ETOT),(uint32_t*)&etot)) cout<< "etot=" << etot <<endl;
137 if(ahlt->getData(Identifier(HltID::EMAX1),(uint32_t*)&e1)) cout<< "e1=" << e1 <<endl;
138 if(ahlt->getData(Identifier(HltID::EMAX2),(uint32_t*)&e2)) cout<< "e2=" << e2 <<endl;
139 if(ahlt->getData(Identifier(HltID::ECOST1),(uint32_t*)&cose1)) cout<< "cose1=" << cose1 <<endl;
140 if(ahlt->getData(Identifier(HltID::ECOST2),(uint32_t*)&cose2)) cout<< "cose2=" << cose2 <<endl;
141 if(ahlt->getData(Identifier(HltID::PMAX1),(uint32_t*)&p1)) cout<< "p1=" << p1 <<endl;
142 if(ahlt->getData(Identifier(HltID::PMAX2),(uint32_t*)&p2)) cout<< "p2=" << p2 <<endl;
143 if(ahlt->getData(Identifier(HltID::EACOP),(uint32_t*)&acop)) cout<< "acop=" << acop <<endl;
144 if(ahlt->getData(Identifier(HltID::EACOL),(uint32_t*)&acole)) cout<< "acole=" << acole <<endl;
145 if(ahlt->getData(Identifier(HltID::ACOL),(uint32_t*)&acol)) cout<< "acol=" << acol <<endl;
146 return;
147}
double p1[4]
double p2[4]
Double_t etot
Double_t e1
Double_t e2
IMessageSvc * msgSvc()
bool isType(string &type) const
Definition DstHltInf.cxx:68
virtual void print() const
Definition DstHltInf.h:76
uint32_t getEventType() const
Definition DstHltInf.h:42
const string & getEventName() const
Definition DstHltInf.cxx:61
StatusCode initialize()
virtual ~EventFilter()
StatusCode execute()
void print(HltInf *)
@ ECOST2
Definition HltID.h:26
@ EMAX2
Definition HltID.h:26
@ ECOST1
Definition HltID.h:26
@ NSHW
Definition HltID.h:25
@ EACOL
Definition HltID.h:26
@ NEMC
Definition HltID.h:25
@ ETOT
Definition HltID.h:25
@ EMAX1
Definition HltID.h:26
@ EACOP
Definition HltID.h:26
@ PMAX2
Definition HltID.h:23
@ PMAX1
Definition HltID.h:22
@ ACOL
Definition HltID.h:23
@ NMDC
Definition HltID.h:22
@ NTRK
Definition HltID.h:22
@ NTOF
Definition HltID.h:24
@ NMUC
Definition HltID.h:28
virtual bool getData(const Identifier &, uint32_t *)
Definition HltInf.cxx:80