4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/SmartDataPtr.h"
17 Algorithm(name, pSvcLocator),
20 declareProperty(
"FilterOutput",m_outfile=
"lv2");
29 MsgStream log(
msgSvc(), name());
30 log << MSG::INFO <<
"in initialize()" << endreq;
32 StatusCode sc = service(
"HltStoreSvc", m_HltStoreSvc);
33 if( sc.isFailure() ) {
34 log << MSG::FATAL << name() <<
": Unable to locate Service HltStoreSvc" << endreq;
38 sc = serviceLocator()->service(
"EventDataSvc", m_evtDataSvc,
true);
39 if (!sc.isSuccess()) {
40 log << MSG::FATAL <<
"Error retrieving EventDataSvc interface IDataProviderSvc." << endreq;
44 NTuplePtr nt(
ntupleSvc(),
"FILE123/EventFilter");
45 if ( nt ) m_tuple = nt;
47 m_tuple=
ntupleSvc()->book(
"FILE123/EventFilter",CLID_ColumnWiseTuple,
"EventFilter");
49 m_tuple->addItem (
"alg", m_alg);
50 m_tuple->addItem (
"nevt", m_nevt);
52 m_tuple->addItem (
"ntof", m_ntof);
53 m_tuple->addItem (
"nemc", m_nemc);
54 m_tuple->addItem (
"nmdc", m_nmdc);
55 m_tuple->addItem (
"nshw", m_nshower);
56 m_tuple->addItem (
"nsec", m_nsec);
57 m_tuple->addItem (
"mbal", m_mbalance);
58 m_tuple->addItem (
"type", m_evttype);
62 m_tuple->addItem (
"nmuc", m_nmuc);
63 m_tuple->addItem (
"etot", m_etot);
64 m_tuple->addItem (
"emax1", m_emax1);
65 m_tuple->addItem (
"emax2", m_emax2);
66 m_tuple->addItem (
"acop", m_acop);
67 m_tuple->addItem (
"ebal", m_ebalance);
68 m_tuple->addItem (
"ebar", m_ebarrel);
69 m_tuple->addItem (
"eend", m_eendcap);
70 m_tuple->addItem (
"ntrk", m_ntrk);
71 m_tuple->addItem (
"pmax1", m_pmax1);
72 m_tuple->addItem (
"pmax2", m_pmax2);
73 m_tuple->addItem (
"acol", m_acol);
74 m_tuple->addItem (
"cost1", m_cost1);
75 m_tuple->addItem (
"cost2", m_cost2);
76 m_tuple->addItem (
"dtof1", m_dtof1);
77 m_tuple->addItem (
"dphi1", m_dphi1);
78 m_tuple->addItem (
"dtof2", m_dtof2);
79 m_tuple->addItem (
"dphi2", m_dphi2);
82 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_tuple) << endmsg;
83 return StatusCode::FAILURE;
103 return StatusCode::SUCCESS;
108 MsgStream log(
msgSvc(), name());
112 StatusCode sc = m_HltStoreSvc->
get(
"EFResult", efResult);
113 if ( sc.isFailure() ) {
114 log << MSG::ERROR <<
" Could not find EFResult" << endreq;
119 log << MSG::ERROR <<
" Unvalid efResult(AnswerIndex==-1)" << endreq;
120 return StatusCode::FAILURE;
123 std::string answer = efResult->
getAnswer();
125 log << MSG::INFO <<
"this event is " << answer << endreq;
127 if (answer ==
"Accepted") {
129 sc = m_HltStoreSvc->
get(
"EventType", evtType);
130 if ( sc.isFailure() ) {
131 log << MSG::ERROR <<
" Could not find EventType" << endreq;
135 log << MSG::ERROR <<
" Unvalid evtType(AnswerIndex==-1)" << endreq;
136 return StatusCode::FAILURE;
138 std::string typeStr = evtType->
getAnswer();
139 log << MSG::INFO <<
" ==> it's marked as " << typeStr << endreq;
142 if(typeStr==
"Junk") m_evttype=0;
143 else if(typeStr==
"GJunk") m_evttype=1;
144 else if(typeStr==
"Beamgas") m_evttype=2;
145 else if(typeStr==
"GBeamgas") m_evttype=3;
146 else if(typeStr==
"Cosmic") m_evttype=4;
147 else if(typeStr==
"GCosmic") m_evttype=5;
148 else if(typeStr==
"EBhabha") m_evttype=6;
149 else if(typeStr==
"GEBhabha") m_evttype=7;
150 else if(typeStr==
"BBhabha") m_evttype=8;
151 else if(typeStr==
"GBBhabha") m_evttype=9;
152 else if(typeStr==
"Dimuon") m_evttype=10;
153 else if(typeStr==
"GDimuon") m_evttype=11;
154 else if(typeStr==
"Diphoton") m_evttype=12;
155 else if(typeStr==
"GDiphoton") m_evttype=13;
156 else if(typeStr==
"Hadron") m_evttype=14;
157 else if(typeStr==
"GHadron") m_evttype=15;
158 else if(typeStr==
"Twophoton") m_evttype=16;
159 else if(typeStr==
"GTwophoton") m_evttype=17;
160 else if(typeStr==
"RandomTrg") m_evttype=31;
161 else if(typeStr==
"Error") m_evttype=30;
162 else if(typeStr==
"Other") m_evttype=29;
165 log << MSG::DEBUG <<
"get event type info: " << m_evttype << endreq;
167 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
169 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
170 return (StatusCode::FAILURE);
172 m_nevt= eventHeader->eventNumber();
173 log << MSG::INFO <<
"EventNo: " << m_nevt <<endl;
174 if(m_evttype==1||m_evttype==3||m_evttype==5) m_notpass.push_back(eventHeader->eventNumber());
186 float nmdc,ntof,nemc,nmuc,nshower,ntrk,nsec;
187 float etot,ebar,eend,ebal,acop,emax1,emax2,dtof1,dphi1,dtof2,dphi2,acol,mbal,pmax1,pmax2;
191 sc = m_HltStoreSvc->
get(
"nmdc", pcri);
192 if ( sc.isFailure() ) nmdc=-9;
194 sc = m_HltStoreSvc->
get(
"nmuc", pcri);
195 if ( sc.isFailure() ) nmuc=-9;
197 sc = m_HltStoreSvc->
get(
"ntof", pcri);
198 if ( sc.isFailure() ) ntof=-9;
200 sc = m_HltStoreSvc->
get(
"nemc", pcri);
201 if ( sc.isFailure() ) nemc=-9;
204 sc = m_HltStoreSvc->
get(
"nshw", pcri);
205 if ( sc.isFailure() ) nshower=-9;
207 sc = m_HltStoreSvc->
get(
"ntrk", pcri);
208 if ( sc.isFailure() ) ntrk=-9;
210 sc = m_HltStoreSvc->
get(
"etot", pcri);
211 if ( sc.isFailure() )
etot=-9;
213 sc = m_HltStoreSvc->
get(
"ebar", pcri);
214 if ( sc.isFailure() ) ebar=-9;
216 sc = m_HltStoreSvc->
get(
"eend", pcri);
217 if ( sc.isFailure() ) eend=-9;
219 sc = m_HltStoreSvc->
get(
"ebal", pcri);
220 if ( sc.isFailure() ) ebal=-9;
222 sc = m_HltStoreSvc->
get(
"acop", pcri);
223 if ( sc.isFailure() ) acop=-9;
225 sc = m_HltStoreSvc->
get(
"emax1", pcri);
226 if ( sc.isFailure() ) emax1=-9;
228 sc = m_HltStoreSvc->
get(
"emax2", pcri);
229 if ( sc.isFailure() ) emax2=-9;
231 sc = m_HltStoreSvc->
get(
"dtof1", pcri);
232 if ( sc.isFailure() ) dtof1=-999;
234 sc = m_HltStoreSvc->
get(
"dphi1", pcri);
235 if ( sc.isFailure() ) dphi1=-9;
237 sc = m_HltStoreSvc->
get(
"dtof2", pcri);
238 if ( sc.isFailure() ) dtof2=-999;
240 sc = m_HltStoreSvc->
get(
"dphi2", pcri);
241 if ( sc.isFailure() ) dphi2=-9;
243 sc = m_HltStoreSvc->
get(
"acol", pcri);
244 if ( sc.isFailure() ) acol=-9;
246 sc = m_HltStoreSvc->
get(
"pmax1", pcri);
247 if ( sc.isFailure() ) pmax1=-9;
249 sc = m_HltStoreSvc->
get(
"pmax2", pcri);
250 if ( sc.isFailure() ) pmax2=-9;
252 sc = m_HltStoreSvc->
get(
"nsec", pcri);
253 if ( sc.isFailure() ) nsec=-9;
255 sc = m_HltStoreSvc->
get(
"mbal", pcri);
256 if ( sc.isFailure() ) mbal=-9;
262 m_nshower=long(nshower);
281 std::vector<uint32_t> efVec=efResult->
getEFVec();
303 log<< MSG::INFO<<efVec<<endreq;
304 log<< MSG::INFO<<acol<<
" "<<
etot<<endreq;
306 StatusCode status = m_tuple->write();
307 if (!status.isSuccess()) {
308 log << MSG::ERROR <<
"Can't fill ntuple!" << endreq;
314 return StatusCode::SUCCESS;
319 MsgStream log(
msgSvc(), name());
320 log << MSG::INFO <<
"in finalize()" << endreq;
323 if(m_notpass.size()>0&&m_outfile!=
"lv2"){
325 outfile.open(m_outfile.c_str(),ios_base::out);
326 for(
unsigned int i=0;i<m_notpass.size();i++){
327 outfile << m_notpass[i] <<endl;
332 return StatusCode::SUCCESS;
Defines the EFResult RDO structure.
CheckEFResult(const std::string &name, ISvcLocator *pSvcLocator)
bool getValue(float &value) const
const std::string getAnswer() const
const int getAnswerIndex() const
const std::vector< uint32_t > getEFVec() const
bool get(const std::string &name, T &value)