BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
EFEventLoopMgr.cxx
Go to the documentation of this file.
1//===================================================================
2//
3// EFEventLoopMgr.cpp
4//--------------------------------------------------------------------
5//
6// Package : EFEventLoopMgr
7//
8// Description: implementation of the Application's batch mode handler
9//
10// Author : TangRui [email protected]
11//
12//====================================================================
13#define GAUDISVC_EFEVENTLOOPMGR_CPP
14#include <stdlib.h>
15
16#include "GaudiKernel/IAlgorithm.h"
17#include "GaudiKernel/SmartIF.h"
18#include "GaudiKernel/Incident.h"
19#include "GaudiKernel/MsgStream.h"
20#include "GaudiKernel/DataSelectionAgent.h"
21#include "GaudiKernel/DataObject.h"
22#include "GaudiKernel/IIncidentSvc.h"
23#include "GaudiKernel/IEvtSelector.h"
24#include "GaudiKernel/IDataManagerSvc.h"
25#include "GaudiKernel/IDataProviderSvc.h"
26#include "GaudiKernel/IConversionSvc.h"
27#include "GaudiKernel/ThreadGaudi.h"
28
34//#include "HltDataTypes/EFBesTimer.h"
35
37
38#include "eformat/eformat.h"
39//#include "eformat/write/eformat.h"
40
43
44extern const CLID& CLID_Event;
45//=========================================================================
46// Standard Constructor
47//=========================================================================
48EFEventLoopMgr::EFEventLoopMgr(const std::string& nam,
49 ISvcLocator* svcLoc)
50: MinimalEventLoopMgr(nam, svcLoc)
51{
52 declareProperty( "EvtSel", m_evtsel );
53 declareProperty( "HistogramPersistency", m_histPersName = "");
54 declareProperty( "DisableEFResult", m_disableEFResult = true);
55 declareProperty( "OkexecuteEvent", m_okexecuteEvent = true);
56 declareProperty( "OutputLevel", m_outputLevel = MSG::ALWAYS);
57 declareProperty( "TimeTest", m_timeTest = 0);
60 m_total_nevt = 0;
61 m_currentRun = 0;
63 m_evtDataSvc = 0;
64 m_evtSelector = 0;
65 m_evtContext = 0;
66 m_firstRun = true;
67 m_incidentSvc = 0;
68 m_trgType = 0;
69 m_firstEvent = true;
70}
71
72//=========================================================================
73// Standard Destructor
74//=========================================================================
76{
77 if( m_histoDataMgrSvc ) m_histoDataMgrSvc->release();
78 if( m_histoPersSvc ) m_histoPersSvc->release();
79 if( m_incidentSvc ) m_incidentSvc->release();
80 if( m_evtDataMgrSvc ) m_evtDataMgrSvc->release();
81 if( m_evtDataSvc ) m_evtDataSvc->release();
82 if( m_evtSelector ) m_evtSelector->release();
83 if( m_evtContext ) delete m_evtContext;
84}
85
86//=========================================================================
87// implementation of IAppMgrUI::initalize
88//=========================================================================
90{
91
92 // initialize the base class
93 StatusCode sc = MinimalEventLoopMgr::initialize();
94 // leave this after initialization of base class, otherwise msgSvc is not correctly set up
95 // -----
96 MsgStream log(msgSvc(), name());
97 log << MSG::INFO << "EFEventLoopMgr:initalize(): ---> EventLoopMgr = " << name() << " initializing " << endreq;
98 if ( !sc.isSuccess() ) {
99 log << MSG::ERROR
100 << "EFEventLoopMgr:initalize():Failed to initialize base class MinimalEventLoopMgr"
101 << endreq;
102 return sc;
103 }
104
105 // Setup access to event data services
106 sc = serviceLocator()->service("EventDataSvc", m_evtDataMgrSvc, true);
107
108 if( !sc.isSuccess() ) {
109 log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataManagerSvc." << endreq;
110 return sc;
111 }
112 sc = serviceLocator()->service("EventDataSvc", m_evtDataSvc, true);
113
114 if( !sc.isSuccess() ) {
115 log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataProviderSvc." << endreq;
116 return sc;
117 }
118
119 //-------------------------------------------------------------------------------
120 // Get the references to the services that are needed by the ApplicationMgr itself
121 //--------------------------------------------------------------------------------
122 sc = serviceLocator()->service("IncidentSvc" , m_incidentSvc, true);
123
124 if( !sc.isSuccess() ) {
125 log << MSG::FATAL << "EFEventLoopMgr:initalize():Error retrieving IncidentSvc" << endreq;
126 return sc;
127 }
128
129 //-------------------------------------------------------------------------------
130 // Get the references to the services that are needed by the ApplicationMgr itself
131 //--------------------------------------------------------------------------------
132 sc = serviceLocator()->service("HltStoreSvc" , m_HltStoreSvc, true);
133 if( !sc.isSuccess() ) {
134 log << MSG::FATAL << "EFEventLoopMgr:initalize():Error retrieving HltStoreSvc" << endreq;
135 return sc;
136 }
137
138 //--------------------------------------------------------------------------
139 // Access Property Manager interface:
140 //--------------------------------------------------------------------------
141 SmartIF<IProperty> prpMgr(serviceLocator());
142 if ( !prpMgr.isValid() ) {
143 log << MSG::FATAL
144 << "EFEventLoopMgr:initalize():IProperty interface not found in ApplicationMgr."
145 << endreq;
146 return StatusCode::FAILURE;
147 }
148
149 //-------------------------------------------------------------------------
150 // Setup Event Setector
151 //-------------------------------------------------------------------------
152 // We do not expect a Event Selector necessarily being declared
153 setProperty(prpMgr->getProperty("EvtSel"));
154
155 if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
156
157 sc = serviceLocator()->service( "EventSelector" , m_evtSelector, true );
158 if( sc.isSuccess() ) { // Setup Event Selector
159 sc=m_evtSelector->createContext(m_evtContext);
160 if( !sc.isSuccess() ) {
161 log << MSG::FATAL << "Can not create the event selector Context." << endreq;
162 return sc;
163 }
164 } else {
165 log << MSG::FATAL << "EFEventLoopMgr:initalize():EventSelector not found." << endreq;
166 return StatusCode::FAILURE;
167 }
168 } else {
169 m_evtSelector = 0;
170 m_evtContext = 0;
171 log << MSG::WARNING
172 << "EFEventLoopMgr:initalize():No service \"EventSelector\" provided : assume \"online\" running "
173 << endreq;
174 }
175
176 //--------------------------------------------------------------------
177 // Get the RawDataInputSvc
178 //--------------------------------------------------------------------
179 IService* svc ;
180 sc = serviceLocator()->getService("RawDataInputSvc", svc);
181 if(sc != StatusCode::SUCCESS ) {
182 log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
183 return sc ;
184 }
185
186 m_inputSvc = dynamic_cast<IRawDataInputSvc*> (svc);
187 if(m_inputSvc == 0 ) {
188 log<<MSG::WARNING << " Cant cast to RawDataInputSvc " <<endreq;
189 return StatusCode::FAILURE ;
190 }
191
192 sc = m_HltStoreSvc->get("EventType", m_evtType);
193 if ( sc.isFailure() ) {
194 log << MSG::ERROR << "Could not find EventType" << endreq;
195 return StatusCode::FAILURE ;
196 }
197 sc = m_HltStoreSvc->get("EFResult", m_efResult);
198 if ( sc.isFailure() ) {
199 log << MSG::ERROR << "Could not find EFResult" << endreq;
200 return StatusCode::FAILURE ;
201 }
202 //cout <<"000000000000000000000000000000 "<<m_timeTest<<endl;
203 if(m_timeTest){
204 //cout <<"111111111111111111111111111111111111"<<endl;
205 //IBesTimerSvc* timerSvc;
206 //sc = service( "BesTimerSvc", timerSvc);
207 //if( sc.isFailure() ) {
208 // log << MSG::WARNING << ": Unable to locate BesTimer Service" << endreq;
209 //}
210 //else{
211 //cout <<"222222222222222222222222222222222222222"<<endl;
212 // pBesTimer=timerSvc->addItem("EventFilterHandler");
213 // if(pBesTimer)pBesTimer->propName("nEventFilterHandler");
214 //}
215 }
216 return StatusCode::SUCCESS;
217}
218
219//=========================================================================
220// implementation of IAppMgrUI::finalize
221//=========================================================================
223{
224 MsgStream log(msgSvc(), name());
225 log << MSG::INFO << " EFEventLoopMgr:finalize():Number of events processed : " << m_total_nevt << endreq;
226
227 if ( m_evtSelector && m_evtContext ) {
228 m_evtSelector->releaseContext(m_evtContext);
229 m_evtContext = 0;
230 }
231
232 m_histoPersSvc = releaseInterface(m_histoPersSvc);
233
234 m_evtSelector = releaseInterface(m_evtSelector);
235 m_incidentSvc = releaseInterface(m_incidentSvc);
236 m_evtDataSvc = releaseInterface(m_evtDataSvc);
237 m_evtDataMgrSvc = releaseInterface(m_evtDataMgrSvc);
238
239 return MinimalEventLoopMgr::finalize();
240}
241
242//=========================================================================
243// executeEvent(void* par) ---> for "online" running
244//=========================================================================
245// the parameter par is an EventFormat::RawMemory::FullEventFragment
246//and it will be feed into Psc::process method
247StatusCode EFEventLoopMgr::executeEvent(void* par)
248{
249
250 StatusCode sc;
251 DataObject* pObject = 0;
252 MsgStream log( msgSvc(), name() );
253 //return StatusCode::SUCCESS;
254 //log << MSG::DEBUG << "EFEventLoopMgr:executeEvent(void* par):Declaring Fragment" << endreq;
255 //if(pBesTimer&&m_timeTest==1){
256 // pBesTimer->start();
257 // pStart=true;
258 //cout<<"time test: start!!!!!!!!!!!!!!!!!!!"<<endl;
259 //}
260 if(m_firstEvent) m_re = new RAWEVENT;
261 else {
262 m_re->reset();
263 m_firstEvent=false;
264 }
265 eformat::FullEventFragment<uint32_t*> pre((uint32_t*)par);
266 try {
267 pre.check_tree();
268 }
269 catch (eformat::Issue& ex) {
270 std::cerr << std::endl
271 << "Uncaught eformat issue: " << ex.what() << std::endl;
272 return StatusCode::FAILURE ;
273 }
274 catch (ers::Issue& ex) {
275 std::cerr << std::endl
276 << "Uncaught ERS issue: " << ex.what() << std::endl;
277 return StatusCode::FAILURE ;
278 }
279 catch (std::exception& ex) {
280 std::cerr << std::endl
281 << "Uncaught std exception: " << ex.what() << std::endl;
282 return StatusCode::FAILURE ;
283 }
284 catch (...) {
285 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
286 return StatusCode::FAILURE ;
287 }
288
289 log << MSG::DEBUG << "[Event No. #" << pre.global_id()
290 << "] " << pre.fragment_size_word() << " words in "
291 << pre.nchildren() << " subdetectors "
292 << endreq;
293
294 m_re->setRunNo(pre.run_no());
295 m_re->setEventNo(pre.global_id());
296 m_re->setTime(pre.time());
297
298 uint32_t *robs[100];
299 int nrobs = eformat::get_robs((uint32_t*)par, (const uint32_t **)robs, 100);
300 if(nrobs>100) log<<MSG::ERROR<< "ROBFragments' number exceeds than 100!"<<endreq;
301
302 for (int robi = 0; robi < nrobs; robi++) {
303 eformat::ROBFragment<uint32_t*> rob(robs[robi]);
304 uint32_t status= rob.rod_detev_type();
305 uint32_t sourceid = rob.rod_source_id();
306 if((status&0x2)&&(sourceid!=0xa50000)) {
307 std::string answer="Error";
308 m_efResult->reset();
309 m_evtType->reset();
310 m_evtType->setAnswer(answer);
311 log << MSG::DEBUG << "detector status is "<<status<<endreq;
312 delete m_re;
313 return StatusCode::SUCCESS;
314 }
315 }
316
317 bool trg=false;
318 for (int robi = 0; robi < nrobs; robi++) {
319 eformat::ROBFragment<uint32_t*> rob(robs[robi]);
320 uint32_t* dataptr = NULL;
321 rob.rod_data(dataptr);
322 vector<uint32_t> DetElements(dataptr, (dataptr+rob.rod_ndata()));
323
324 uint32_t source_id_number = rob.rod_source_id();
325 //std::cout<<"#####source_id_number#####"<<source_id_number<<std::endl;
326 source_id_number <<= 8;
327 source_id_number >>= 24;
328 //std::cout<<"#####(source_id_number<<24)>>29#####"<<source_id_number<<std::endl;
329 //be careful here!!!
330 log<<MSG::DEBUG<< source_id_number << " Digi size="<<DetElements.size()<<endreq;
331 switch(source_id_number)
332 {
333 case 161:
334 m_re->addReMdcDigi(dataptr,DetElements.size());
335 //if(DetElements.size()>0)std::cout<<hex<<DetElements[0]<<std::endl;
336 break;
337 case 163:
338 m_re->addReEmcDigi(dataptr,DetElements.size());
339 break;
340 case 162:
341 //std::cout<<"EFEventLoopMgr::TOFDigi size="<<DetElements.size()<<std::endl;
342 m_re->addReTofDigi(dataptr,DetElements.size());
343 break;
344 case 164:
345 //std::cout<<"EFEventLoopMgr::MUCDigi size="<<DetElements.size()<<std::endl;
346 m_re->addReMucDigi(dataptr,DetElements.size());
347 break;
348 case 165:
349 trg=getTrigChn(dataptr,rob.rod_ndata());
350 break;
351 default:
352 //std::cerr << "no such subdetector type!" << std::endl;
353 break;
354 }
355 if(trg){
356 std::string answer="RandomTrg";
357 m_efResult->reset();
358 m_evtType->reset();
359 m_evtType->setAnswer(answer);
360 log << MSG::DEBUG << "a random trigger event is taken" << endreq;
361 m_re->reset();
362 return StatusCode::SUCCESS;
363 }
364 }
365 //if(pBesTimer&&m_timeTest==2){
366 // pBesTimer->start();
367 // pStart=true;
368 //cout<<"time test: start!!!!!!!!!!!!!!!!!!!"<<endl;
369 //}
370 if(!(m_inputSvc->setCurrentEvent(m_re))) {
371 log << MSG::FATAL << "m_inputSvc->setCurrentEvent(m_re) Failed!" << endreq;
372 exit(1);
373 }
374
375 if( 0 != m_total_nevt ) {
376 sc = m_evtDataMgrSvc->clearStore();
377 if( !sc.isSuccess() ) {
378 log << MSG::DEBUG << "Clear of Event data store failed" << endreq;
379 }
380 }
381
382 // Create event address in the event store
383 IOpaqueAddress* addr = new RawDataAddress(CLID_Event, "EventHeader", "EventHeader");
384
385 // Set root clears the event data store first
386 sc = m_evtDataMgrSvc->setRoot ("/Event", addr);
387 if( !sc.isSuccess() ) {
388 log << MSG::WARNING << "Error declaring event root address." << endreq;
389 return sc;
390 }
391 sc = m_evtDataSvc->retrieveObject("/Event", pObject);
392 if( !sc.isSuccess() ) {
393 log << MSG::WARNING << "Unable to retrieve Event root object" << endreq;
394 return sc;
395 }
396
397 m_total_nevt++;
398 // Fire BeginEvent "Incident"
399 m_incidentSvc->fireIncident(Incident(name(), "BeginEvent"));
400 // Execute Algorithms
401 sc = MinimalEventLoopMgr::executeEvent(NULL);
402 // Fire EndEvent "Incident"
403 m_incidentSvc->fireIncident(Incident(name(), "EndEvent"));
404
405 //if(pBesTimer){
406 // pBesTimer->stop();
407 // double time=pBesTimer->elapsed();
408 // std::cout<<"Run time="<<time<<std::endl;
409 //}
410 //delete addr;
411 //delete m_re;
412 return sc;
413}
414
415/// Create event address using event selector
416StatusCode EFEventLoopMgr::getEventRoot(IOpaqueAddress*& refpAddr) {
417 refpAddr = 0;
418 StatusCode sc = m_evtSelector->next(*m_evtContext);
419 if ( !sc.isSuccess() ) {
420 return sc;
421 }
422 // Create root address and assign address to data service
423 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
424 if( !sc.isSuccess() ) {
425 sc = m_evtSelector->next(*m_evtContext);
426 if ( sc.isSuccess() ) {
427 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
428 if ( !sc.isSuccess() ) {
429 MsgStream log( msgSvc(), name() );
430 log << MSG::WARNING << "Error creating IOpaqueAddress." << endreq;
431 }
432 }
433 }
434 return sc;
435}
436
437//----------------------------------------------------------------------------------
438// implementation of IInterface: queryInterface
439//----------------------------------------------------------------------------------
440StatusCode EFEventLoopMgr::queryInterface(const InterfaceID& riid, void** ppvInterface) {
441 if ( IEFEventLoopMgr::interfaceID().versionMatch(riid) ) {
442 *ppvInterface = (IEFEventLoopMgr*)this;
443 }
444 else {
445 return MinimalEventLoopMgr::queryInterface(riid, ppvInterface);
446 }
447 addRef();
448 return StatusCode::SUCCESS;
449}
450
451//=========================================================================
452// EF: prepare for run step ---> for "online" running
453//=========================================================================
454StatusCode EFEventLoopMgr::prepareForRun(int ef_run_number)
455{
456 MsgStream log( msgSvc(), name() );
457 StatusCode sc;
458 int run_num = ef_run_number;
459 log << MSG::DEBUG << " ---> EFprepareForRun::Received run number from PT = "
460 << run_num << endreq;
461
462 log << MSG::DEBUG
463 << " ---> EFprepareForRun::Setup IOVSvc for run number = "
464 << run_num << endreq;
465 const EventInfo* pEvent = new EventInfo(new EventID(run_num,0), new EventType());
466
467 //hxt sc = m_StoreGateSvc->record(pEvent,"");
468 if(m_currentRun!=run_num) m_incidentSvc-> fireIncident(Incident(name(),"NewRun"));
469 m_currentRun = run_num;
470 //Fire BeginRun "Incident"
471 //m_incidentSvc-> fireIncident(EventIncident(*pEvent, name(),"BeginRun"));
472 m_incidentSvc-> fireIncident(Incident(name(),"BeginRun"));
473 return StatusCode::SUCCESS;
474}
475
476//=========================================================================
477// EFResult() ---> for "online" running
478//=========================================================================
479//3 possible EFDecisions exist: "Accepted", "Rejected", "Error"
481{
482 MsgStream log( msgSvc(), name() );
483 if (m_disableEFResult) {
484 std::string defaultEFDecision = "Other" ;
485 log << MSG::WARNING
486 << "EFEventLoopMgr:EF_Decision():---> EFResult handling is disabled. Default EFDecision = "
487 << defaultEFDecision
488 << endreq;
489 if (m_okexecuteEvent!=1){
490 std::string defaultEFDecision = "Error";
491 log << MSG::WARNING
492 << "EFEventLoopMgr:EF_Decision():---> Error in executeEvent, setting EFDecision to: "<< defaultEFDecision << endreq;
493 return defaultEFDecision;
494 }
495 return defaultEFDecision;
496 }
497 else {
498 //log << MSG::DEBUG << "Try to get the EFDecision" << endreq;
499
500 //StatusCode sc = m_HltStoreSvc->get("EFResult", m_efResult);
501 //enrich the result returned to online
502 //by Fu Chengdong
503 if (m_evtType->getAnswerIndex() == -1) {
504 log << MSG::DEBUG << "EF_Decision(): Unvalid EFResult(AnswerIndex=-1)" << endreq;
505 return "Error";
506 }
507 std::string answer = m_evtType->getAnswer();
508 log << MSG::INFO << "The answer is " << answer << endreq;
509 return answer;
510 }
511}
512
514{
515 MsgStream log( msgSvc(), name() );
516 uint32_t x=1;
517 uint32_t y=0;
518 uint32_t z=0;
519 uint32_t version=(x<<16)+(y<<8)+z;
520 log << MSG::INFO << "The version is " <<version << endreq;
521 return version;
522}
524{
525 MsgStream log( msgSvc(), name() );
526 uint32_t alg=m_efResult->getEFVec(0);
527 //log << MSG::INFO << "The algorithm tag is " << alg<<endreq;
528 int itype=m_evtType->getMidAnswerIndex();
529 //cout <<itype<<endl;
530 if(itype != -1) alg += (1<<itype);
531 uint32_t alg16=alg>>16;
532 log << MSG::DEBUG << "The algorithm tag is " << alg <<":"
533 << (alg&1)<<((alg>>1)&1)<<((alg>>2)&1)<<((alg>>3)&1)
534 <<((alg>>4)&1)<<((alg>>5)&1)<<((alg>>6)&1)<<((alg>>7)&1)
535 << ":%# "<< alg16<<endreq;
536 return alg;
537}
538
540{
541 MsgStream log( msgSvc(), name() );
542 uint32_t etot=m_efResult->getEFVec(31);
543 log << MSG::INFO << "The total energy is " <<*((float*)&etot) <<"GeV"<<endreq;
544 return etot;
545}
546//This method should return a pointer to the local memory containing the EF SubDetectorFragment
548{
549 //std::cout << "jak:"<<__FILE__<<std::endl;
550 MsgStream log( msgSvc(), name() );
551
552 if (m_disableEFResult) {
553 log << MSG::WARNING << "EFEventLoopMgr:EF_Fragment_Address():---> EFResult handling is disabled!!!! No pointer to EF Fragment will be given." << endreq;
554 return NULL;
555
556 }
557 else {
558
559 //log << MSG::DEBUG << "EFEventLoopMgr:EF_Fragment_Address():---> Going to retrieve EFResult, for the Fragment Address"<<endreq;
560 uint32_t alg=m_efResult->getEFVec(0);
561 log << MSG::DEBUG << "alg="<<alg<<endreq;
562 uint32_t num=m_efResult->getEFVec(1);
563 int nmdc=num&0xFF;
564 int ntof=(num>>8)&0xFF;
565 int nemc=(num>>16)&0xFF;
566 int nmuc=(num>>24)&0xFF;
567 int ndata=1;
568 uint32_t ndatap = nmdc+ntof+nemc+nmuc;
569 ndata += ndatap;
570 int ndec=m_efResult->getDecNum();
571 if(ndec>0) ndata +=(ndec+1);
572 if((alg&4)&&(!(alg&2))) log << MSG::WARNING<<"sub-algorithms error!"<<endreq;
574 log << MSG::FATAL << "data length error!" <<endreq;
575 return NULL;
576 }
577 log << MSG::INFO<< "sent data lenth=" << ndata+40<<endreq;//byjak
578 //uint32_t* efAddress=malloc((ndata+ONLINE_DATA_HEAD+ONLINE_DATA_TAIL)*sizeof(uint32_t));
579 uint32_t* efAddress=new uint32_t[ndata+ONLINE_DATA_HEAD+ONLINE_DATA_TAIL];
580 //std::cout << "fucd-->Address" << efAddress << "; ndata="<<ndata<<std::endl;
581 if(efAddress==NULL) return NULL;
582 efAddress[0]=0xbb1234bb;
583 efAddress[1]=ndata+ONLINE_DATA_HEAD+ONLINE_DATA_TAIL;
584 efAddress[2]=8;
585 efAddress[3]=0x3000000;
586 efAddress[4]=0x7c0000;
587 efAddress[5]=1;
588 efAddress[6]=0;
589 efAddress[7]=0;
590 efAddress[8]=0xcc1234cc;
591 efAddress[9]=efAddress[1]-efAddress[2];
592 efAddress[10]=0xb;
593 efAddress[11]=0x3000000;
594 efAddress[12]=0x7c0000;
595 efAddress[13]=1;
596 efAddress[14]=0;
597 efAddress[15]=3;
598 efAddress[16]=0;
599 efAddress[17]=0;
600 efAddress[18]=0;
601 efAddress[19]=0xdd1234dd;
602 efAddress[20]=efAddress[9]-efAddress[10];
603 efAddress[21]=8;
604 efAddress[22]=0x3000000;
605 efAddress[23]=0x7c0000;
606 efAddress[24]=1;
607 efAddress[25]=0;
608 efAddress[26]=0;
609 efAddress[27]=0xee1234ee;
610 efAddress[28]=9;
611 efAddress[29]=0x3000000;
612 efAddress[30]=0x7c0000;
613 efAddress[31]=0;
614 efAddress[32]=0;
615 efAddress[33]=0;
616 efAddress[34]=0;
617 efAddress[35]=0;
618 //efAddress[36]=0;
619 efAddress[36+ndata]=0;
620 efAddress[37+ndata]=1;
621 efAddress[38+ndata]=ndata;
622 efAddress[39+ndata]=1;
623 efAddress[ONLINE_DATA_HEAD]=m_efResult->getEFVec(1);
624 if(ndata==1){
625 return efAddress;
626 }
627 else{
628 unsigned int i=1;
629 for(int j=5;j<5+nmdc;j++){
630 efAddress[ONLINE_DATA_HEAD+i]=m_efResult->getEFVec(j);
631 ++i;
632 }
633 for(int j=25;j<25+ntof;j++){
634 efAddress[ONLINE_DATA_HEAD+i]=m_efResult->getEFVec(j);
635 ++i;
636 }
637 for(int j=30;j<30+nemc;j++){
638 efAddress[ONLINE_DATA_HEAD+i]=m_efResult->getEFVec(j);
639 ++i;
640 }
641 for(int j=52;j<52+nmuc;j++){
642 efAddress[ONLINE_DATA_HEAD+i]=m_efResult->getEFVec(j);
643 ++i;
644 }
645 if(ndec>0) {
646 efAddress[ONLINE_DATA_HEAD+i]=ndec;
647 ++i;
648 for(int j=54;j<54+ndec;++j){
649 efAddress[ONLINE_DATA_HEAD+i]=m_efResult->getEFVec(j);
650 ++i;
651 }
652 }
653 log << MSG::DEBUG <<"0th eff data is "
654 <<((efAddress[ONLINE_DATA_HEAD]>>24)&0xFF)
655 <<((efAddress[ONLINE_DATA_HEAD]>>16)&0xFF)
656 <<((efAddress[ONLINE_DATA_HEAD]>>8)&0xFF)
657 <<((efAddress[ONLINE_DATA_HEAD]>>0)&0xFF)<<endreq;
658 for(int i=1;i<ndatap+1;i++){
659 log << MSG::DEBUG <<i<<"th eff data is " <<*((float*)&(efAddress[ONLINE_DATA_HEAD+i]))<<endreq;
660 }
661 for(int i=ndatap+1;i<ndata;i++){
662 log << MSG::DEBUG <<i<<"th eff data is " << efAddress[ONLINE_DATA_HEAD+i]<<endreq;
663 }
664 return efAddress;
665 }
666
667 return NULL;
668
669 //FullEventAssembler<EFSrcIdMap> fea ;
670
671 /** EF ROD */
672 //FullEventAssembler<EFSrcIdMap>::RODDATA* EFROD ;
673 //EventFormat::SourceID helpEFID(EventFormat::TDAQ_EVENT_FILTER,EventFormat::ROD_TYPE,0);
674 //uint32_t rodIdEF = helpEFID.source_id();
675
676 /* Create the ROD data container to be filled later */
677 //EFROD = fea.getRodData( rodIdEF );
678
679 //std::vector<uint32_t> efVec(m_efResult->getEFVec());
680
681 //for (std::vector<uint32_t>::iterator i=efVec.begin();
682 // i!=efVec.end();++i)
683 //{
684 // EFROD->push_back(*i);
685 // }
686
687
688 /** Create an emply RawEvent and fill the RODs into the RawEvent (FullEventFragment) re */
689
690 //Get ByteStreamCnvSvc
691
692 // StatusCode sc;
693
694
695 //Get ByteStreamCnvSvc
696//hxt if(StatusCode::SUCCESS != service("ByteStreamCnvSvc",m_ByteStreamEventAccess)){
697//hxt log << MSG::ERROR << " EFEventLoopMgr:EF_Fragment_Address():Can't get ByteStreamEventAccess interface " << endreq;
698//hxt return NULL;
699//hxt }
700
701 //Obtain the RawEvent
702 /*
703 log <<MSG::INFO<< "EFEventLoopMgr:EF_Fragment_Address(): Abans del get RawEvent" << endreq;
704
705 RawEvent* re = m_ByteStreamEventAccess->getRawEvent();
706
707 log << MSG::INFO <<"EFEventLoopMgr:EF_Fragment_Address(): Despres del get RawEvent" << endreq;
708 */
709
710 //fea.fill(re,log);
711
712
713 //To serialize RawEvent and obtain a pointer to the memory address
714 //where the EF SubdetectorFragment is
715
716
717 //Now get SubdetectorFragment from Raw Event
718 /*
719 const VDETF& vdetf=re->compounds();
720
721 log << MSG::DEBUG<< " EFEventLoopMgr:EF_Fragment_Address(): Full Event:" << hex << "Full source ID: " << re->header().source_id() <<endreq;
722 log << MSG::DEBUG<< " EFEventLoopMgr:EF_Fragment_Address(): Fragment size in words:" << re->header().fragment_size_word()<<endreq;
723 log << MSG::DEBUG<< " EFEventLoopMgr:EF_Fragment_Address(): # of subdetectors:" <<vdetf.size()<<endreq;
724
725
726 VDETF::const_iterator it_detf = vdetf.begin();
727 VDETF::const_iterator it_detf_end = vdetf.end();
728
729
730 //Loop over all Subdetectors
731
732 for(; it_detf!=it_detf_end; ++it_detf){
733
734
735
736 if(!((*it_detf)->is_valid())){
737
738 log<< MSG::ERROR << "EFEventLoopMgr:EF_Fragment_Address():Got invalid subdetector fragment!. A null pointer will be returned" << endreq;
739 return NULL;
740 }
741
742 // Get the size of the SubDet fragment in WORDS
743 int fragSize = (*it_detf)->size_word();
744
745 //Now like in ptdummy::Steering
746
747
748 // Create a NEW memory storage (it mallocs a new region in "local" memory)
749 EventFormat::RawMemoryStorage store(fragSize*4);
750
751 // Serialize the subDetector fragment on the store (on the "local" buffer)
752 (*it_detf)->serialise(store);
753
754 log << MSG::DEBUG<< " EFEventLoopMgr:EF_Fragment_Address():SubDetectorFragment serialized on 'local memory.'" <<endreq;
755
756
757
758 // Return to pt::Worker the address (p) of the "local" memory region
759 // containing the serialized EF fragment
760
761 m_serializedEFAddress=(char*)store.address();
762
763 // Release the ownership of the 'local' memory region containing the
764 // serialized Fragment (i.e.: exiting from process() the storage distructor
765 // will not delete this memory region)
766 // The memory region MUST be deleted by pt::worker !!!
767
768 store.release_memory();
769 }
770 return m_serializedEFAddress;
771 */
772 }
773
774 return NULL;
775}
776
777bool EFEventLoopMgr::getTrigChn(uint32_t* data, uint32_t ndata){
778 MsgStream log( msgSvc(), name() );
779 log << MSG::DEBUG << ndata<<":"<<(*data)<<","<<endreq;
780 uint32_t index = 0;
781
782 while (ndata - index > 1) {
783 uint32_t header= *(data+index);
784 uint32_t blockSize = ( (header>>14) & 0x3FF);
785 uint32_t id = (header>>24);
786 //std::cout << "TriggerChannel:" << hex<<header << "==>" << blockSize<<","<<id
787 // << ","<<((header >> 8) & 0x3F) << dec<<std::endl;
788 if (blockSize == 0 || (index+blockSize) > ndata) break;
789 if (id==0xD3) {
790 uint32_t window = ((header >> 8) & 0x3F); //Time window, bit8 to bit13, total: 0--31
791 uint32_t size= blockSize-1;
792 if(window==0){
793 log << MSG::FATAL << "window=0" << endreq;
794 //return false;
795 }
796 else if(size%window != 0) {
797 log << MSG::FATAL << "GTL data is NOT completed" << endreq;
798 //return false;
799 }
800 //vector<uint32_t> trigData(data+index+1, data+index+size);
801 for(uint32_t j = 0; j < size; j++) {
802 uint32_t trgdata = *(data+index+1+j);
803 uint32_t dataId = ((trgdata >> 24) & 0x7);
804 //std::cout <<hex<< trgdata << "==>"<< dataId <<"," << (trgdata&0xFFFFFF)<<dec<<std::endl;
805 if(dataId!=5) continue;
806 //std::cout <<hex<< trgdata <<dec<<std::endl;
807 m_trgType= m_trgType|(trgdata&0xFFFF);
808 if(trgdata&(1<<9)) return true;
809 //if(trgdata&(1<<8)) return true;
810 //if(trgdata&(1<<10)) return true;
811 }
812 }
813 index += blockSize;
814 }
815 //cout<<m_trgType<<endl;
816
817 return false;
818}
TTree * data
Double_t etot
Double_t x[10]
const CLID & CLID_Event
Definition: EventModel.cxx:189
#define ONLINE_DATA_TAIL
Definition: EFEventLoopMgr.h:8
#define ONLINE_DATA_HEAD
Definition: EFEventLoopMgr.h:7
Defines the EFResult RDO structure.
const CLID & CLID_Event
Definition: EventModel.cxx:189
IMessageSvc * msgSvc()
virtual bool getTrigChn(uint32_t *data, uint32_t ndata)
whether it is a RrandomTrg
std::string m_evtsel
Event selector.
virtual StatusCode executeEvent(void *par)
implementation of IEventProcessor::executeEvent(void* par)
IConversionSvc * m_histoPersSvc
Reference to the Histogram Persistency Service.
virtual ~EFEventLoopMgr()
Standard Destructor.
std::string m_histPersName
Name of the Hist Pers type.
virtual StatusCode initialize()
implementation of IAppMgrUI::initalize
virtual std::string EF_Decision()
return data from EF decision
virtual StatusCode finalize()
implementation of IAppMgrUI::finalize
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
EventID::number_type m_currentRun
current run number
virtual uint32_t EF_Version()
return version number
EFEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
virtual uint32_t EF_Total_Energy()
return total energy
IIncidentSvc * m_incidentSvc
Reference to the indicent service.
virtual uint32_t * EF_Fragment_Address()
Return a pointer to the local memory containing the EF subdetector fragment.
virtual StatusCode prepareForRun(int ef_run_number)
prepare for run step
IDataManagerSvc * m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
implementation of IInterface: queryInterface
IEvtSelector::Context * m_evtContext
Event Context.
IDataProviderSvc * m_evtDataSvc
Reference to the Event Data Service's IDataProviderSvc interface.
virtual uint32_t EF_Algorithm_Tag()
return algorithm tag
IDataManagerSvc * m_histoDataMgrSvc
Reference to the Histogram Data Service.
HltStoreSvc * m_HltStoreSvc
Reference to HltStoreSvc;.
IEvtSelector * m_evtSelector
Reference to the Event Selector.
const int getDecNum() const
Definition: EFResult.h:68
const std::string getAnswer() const
Definition: EFResult.cxx:169
const int getMidAnswerIndex() const
Definition: EFResult.cxx:175
void setAnswer(std::string &answer)
Definition: EFResult.cxx:118
const int getAnswerIndex() const
Definition: EFResult.cxx:171
void reset()
Definition: EFResult.cxx:156
const std::vector< uint32_t > getEFVec() const
Definition: EFResult.cxx:51
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
Definition: EventInfo.h:34
bool get(const std::string &name, T &value)
Definition: HltStoreSvc.h:76
static const InterfaceID & interfaceID()
Retrieve interface ID.
virtual bool setCurrentEvent(RAWEVENT *)=0
void addReTofDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:59
void setRunNo(uint32_t run_no)
Definition: RAWEVENT.h:46
void addReMdcDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:53
void addReMucDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:62
void setTime(uint32_t time)
Definition: RAWEVENT.h:48
void setEventNo(uint32_t event_no)
Definition: RAWEVENT.h:47
void addReEmcDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:56
void reset()
Definition: RAWEVENT.cxx:6
virtual uint32_t nchildren() const
Definition: Header.h:263
uint32_t fragment_size_word() const
Definition: Header.h:100
void rod_data(TPointer &it) const
Definition: ROBFragment.h:257
uint32_t rod_source_id() const
Definition: ROBFragment.h:115
uint32_t rod_ndata() const
Definition: ROBFragment.h:159
uint32_t rod_detev_type() const
Definition: ROBFragment.h:140
Root Issue class.
const char * what() const
Human description message.
Includes all entities from the Event Format Library (eformat)
size_t get_robs(const uint32_t *fragment, const uint32_t **rob, size_t max_count)
Definition: util.cxx:105
int num[96]
Definition: ranlxd.c:373