44 {
45
46 MsgStream log(
msgSvc(), name() );
47 log << MSG::DEBUG << "in execute()" << endmsg;
48
49 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
50 if ( !eventHeader )
51 {
52 log << MSG::FATAL << "Could not find Event Header" << endmsg;
53 return StatusCode::FAILURE;
54 }
55
56 int eventId = eventHeader->eventNumber();
57 int runId = eventHeader->runNumber();
58 log << MSG::INFO << "retrieved event: "
59 << "Event Number " << eventId << " run: " << runId << endmsg;
60
62
63 EFResult* efResult;
64 string answer = "";
65 StatusCode sc = m_HltStoreSvc->get( "EventType", efResult );
66 if ( sc.isFailure() )
67 {
68 log << MSG::ERROR << "Could not find EFResult (EventType)" << endmsg;
69 answer = "Error";
70 }
71 else
72 {
74 {
75 log << MSG::DEBUG << "Unvalid EFResult(AnswerIndex=-1)" << endmsg;
76 answer = "Error";
77 }
79 }
80 log << MSG::INFO << "The answer is " << answer << endmsg;
81
82 uint32_t type = 0;
83 if ( answer == "Junk" ) type = 1 << 0;
84 else if ( answer == "GJunk" ) type = ( 1 << 1 );
85 else if ( answer == "Beamgas" ) type = 1 << 2;
86 else if ( answer == "GBeamgas" ) type = ( 1 << 3 );
87 else if ( answer == "Cosmic" ) type = 1 << 4;
88 else if ( answer == "GCosmic" ) type = ( 1 << 5 );
89 else if ( answer == "EBhabha" ) type = 1 << 6;
90 else if ( answer == "GEBhabha" ) type = ( 1 << 7 );
91 else if ( answer == "BBhabha" ) type = 1 << 8;
92 else if ( answer == "GBBhabha" ) type = ( 1 << 9 );
93 else if ( answer == "Dimuon" ) type = 1 << 10;
94 else if ( answer == "GDimuon" ) type = ( 1 << 11 );
95 else if ( answer == "Diphoton" ) type = 1 << 12;
96 else if ( answer == "GDiphoton" ) type = ( 1 << 13 );
97 else if ( answer == "Hadron" ) type = 1 << 14;
98 else if ( answer == "GHadron" ) type = ( 1 << 15 );
99 else if ( answer == "Twophoton" ) type = 1 << 16;
100 else if ( answer == "GTwophoton" ) type = ( 1 << 17 );
101 else if ( answer == "RandomTrg" ) type = 1 << 31;
102 else if ( answer == "Error" ) type = 1 << 30;
103 else if ( answer == "Other" ) type = 1 << 29;
104 else type = 1 << 28;
105
106 uint32_t id = 0x50000000;
107 HltRaw* efType = new HltRaw( id );
109 aEF->push_back( efType );
110
111 sc = m_HltStoreSvc->get( "EFResult", efResult );
112 if ( sc.isFailure() )
113 {
114 log << MSG::FATAL << "Could not find EFResult (EFResult)" << endmsg;
115 return StatusCode::FAILURE;
116 }
117 else
118 {
119 uint32_t alg = efResult->
getEFVec( 0 );
120 id++;
121 HltRaw* efAlg = new HltRaw( id );
122 uint32_t alg8 = alg & 0xFF;
124 aEF->push_back( efAlg );
125 id++;
126 uint32_t cri = alg >> 8;
127 HltRaw* efCri = new HltRaw( id );
129 aEF->push_back( efCri );
130 id++;
131 HltRaw* efVer = new HltRaw( id );
133 aEF->push_back( efVer );
135 id++;
136 HltRaw* efEtot = new HltRaw( id );
138 aEF->push_back( efEtot );
139
141 int nmdc =
num & 0xFF;
142 int ntof = (
num >> 8 ) & 0xFF;
143 int nemc = (
num >> 16 ) & 0xFF;
144 int nmuc = (
num >> 24 ) & 0xFF;
145 int ndata = 1;
146
147 uint32_t ndatap = nmdc + ntof + nemc + nmuc;
148 ndata += ndatap;
150 if ( ndec > 0 ) ndata += ( ndec + 1 );
151
152 log << MSG::DEBUG << "ndata=" << ndata << "; nmdc=" << nmdc << ", ntof=" << ntof
153 << ", nemc=" << nemc << ", nmuc=" << nmuc << ", ndec=" << ndec << endmsg;
154
155 if ( ( alg & 4 ) && ( !( alg & 2 ) ) )
156 log << MSG::WARNING << "sub-algorithms error!" << endmsg;
157
158 uint32_t* var = new uint32_t[ndata];
159 if ( ndata == 1 ) { var[0] = 0; }
160 else
161 {
163 int i = 1;
164 for ( int j = 5; j < 5 + nmdc; j++ )
165 {
167 ++i;
168 }
169 for ( int j = 25; j < 25 + ntof; j++ )
170 {
172 ++i;
173 }
174 for ( int j = 30; j < 30 + nemc; j++ )
175 {
177 ++i;
178 }
179 for ( int j = 52; j < 52 + nmuc; j++ )
180 {
182 ++i;
183 }
184 if ( ndec > 0 )
185 {
186 var[i] = ndec;
187 ++i;
188 for ( int j = 54; j < 54 + ndec; ++j )
189 {
191 ++i;
192 }
193 }
194 if ( i != ndata ) log << MSG::FATAL << "number of datat error!" << endmsg;
195 }
196
197 id++;
198 HltRaw* efTag = new HltRaw( id );
200 aEF->push_back( efTag );
201
202 for ( int i = 1; i < ndata; i++ )
203 {
204 id++;
205 HltRaw* efVar =
new HltRaw(
HltID::convert(
id, nmdc, ntof, nemc, nmuc ) );
208 aEF->push_back( efVar );
209 }
210 delete var;
211 }
212
213 uint32_t atype = 0, alg = 0, cri = 0, ver = 0;
215
216 DataObject* aHltEvent;
217 eventSvc()->findObject( "/Event/Hlt", aHltEvent );
218 if ( aHltEvent == NULL )
219 {
220 log << MSG::INFO << "HltEvent has not existed, so register it now!" << endmsg;
221 HltEvent* aHlt = new HltEvent();
223 if ( sc != StatusCode::SUCCESS )
224 {
225 log << MSG::FATAL << "Could not register Hlt!!!" << endmsg;
226 return ( StatusCode::FAILURE );
227 }
228 }
229 else { log << MSG::WARNING << "HltEvent has existed!" << endmsg; }
230
231 DataObject* aHltRawEvent;
232 eventSvc()->findObject( "/Event/Hlt/HltRawCol", aHltRawEvent );
233 if ( aHltRawEvent != NULL )
234 {
235 SmartDataPtr<HltRawCol> hltRawCol( eventSvc(), "/Event/Hlt/HltRawCol" );
236 HltRawCol::iterator
iter = hltRawCol->begin();
237 for ( ;
iter != hltRawCol->end();
iter++ )
238 {
239 Identifier id = ( *iter )->identify();
245 }
246 log << MSG::DEBUG << "old type=" << atype << ", alg=" << alg << ", criteria=" << cri
247 <<
", version=" << ver <<
", energy=" <<
etot << endmsg;
248
249 sc = eventSvc()->unregisterObject( "/Event/Hlt/HltRawCol" );
250 delete aHltRawEvent;
251 log << MSG::INFO << "Old raw collection has been unregistered" << endmsg;
252 if ( sc != StatusCode::SUCCESS )
253 {
254 log << MSG::FATAL << "Could not unregister HLT raw collection" << endmsg;
255 return ( StatusCode::FAILURE );
256 }
257 }
258
259
261 if ( sc != StatusCode::SUCCESS )
262 {
263 log << MSG::FATAL << "Still could not register HltRawCol" << endmsg;
264 return StatusCode::FAILURE;
265 }
266
267 SmartDataPtr<HltRawCol> hltRawCol( eventSvc(), "/Event/Hlt/HltRawCol" );
268 if ( !hltRawCol )
269 {
270 log << MSG::FATAL << "Could not find HltRawCol!" << endmsg;
271 return StatusCode::FAILURE;
272 }
273
274 HltRawCol::iterator
iter = hltRawCol->begin();
275 for ( ;
iter != hltRawCol->end();
iter++ )
276 {
277 Identifier id = ( *iter )->identify();
283 }
284 log << MSG::DEBUG << " type=" << atype << ", alg=" << alg << ", criteria=" << cri
285 <<
", version=" << ver <<
", energy=" <<
etot << endmsg;
286
287 return StatusCode::SUCCESS;
288}
ObjectVector< HltRaw > HltRawCol
const int getDecNum() const
const std::string getAnswer() const
const int getAnswerIndex() const
const std::vector< uint32_t > getEFVec() const
static bool is_version(const Identifier &id)
static bool is_eventtype(const Identifier &id)
static Identifier convert(const unsigned int id, const int nmdc=0, const int ntof=0, const int nemc=0, const int nmuc=0)
convert global id to sub-id(Identifier)
static bool is_algorithm(const Identifier &id)
static bool is_criteria(const Identifier &id)
static bool is_energy(const Identifier &id)
void setIntChannel(const unsigned int intChannel)
void setFloatChannel(const float value)
_EXTERN_ std::string Event
_EXTERN_ std::string HltRawCol