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