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