BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
OfflineEvtFilterAlg.cxx
Go to the documentation of this file.
4
6#include "DstEvent/DstEvent.h"
10#include "HltEvent/HltEvent.h"
11#include "HltEvent/DstHltInf.h"
13
14#include "GaudiKernel/AlgFactory.h"
15#include "GaudiKernel/Incident.h"
16#include "GaudiKernel/IIncidentSvc.h"
17
18// Declaration of the Algorithm Factory
20
21//=============================================================================
22// Standard constructor, initializes variables
23//=============================================================================
25 ISvcLocator* pSvcLocator)
26: GaudiAlgorithm ( name , pSvcLocator )
27{
28}
29//=============================================================================
30// Destructor
31//=============================================================================
33
34//=============================================================================
35// Initialization
36//=============================================================================
38 StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first
39 if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm
40
41 debug() << "==> Initialize" << endmsg;
42
43 sc = service("OfflineEvtFilterSvc", m_evtFilterSvc);
44 if ( sc != StatusCode::SUCCESS ) {
45 fatal() << "can not use OfflineEvtFilterSvc" << endreq;
46 return sc;
47 }
48
49 m_dataSvc = eventSvc();
50 m_incidentSvc = svc<IIncidentSvc>("IncidentSvc",true);
51
52 return StatusCode::SUCCESS;
53}
54
55//=============================================================================
56// Main execution
57//=============================================================================
59
60 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
61
62 // whether to keep this event for further reconstruction
63 bool keep = true;
64 int npar = m_evtFilterSvc->getNpar();
65
66 int iPar = 0;
67 /// filter with ets-ist
68 if ( eventHeader->etsFlag() != 21 ) {
69 double dtEts = (long(eventHeader->etsT1()) - long(eventHeader->etsT2())) / double(2000.); //in ms
70 for ( ; iPar < npar && m_evtFilterSvc->getFlag(iPar) == 0; ++iPar ) {
71 if ( dtEts < m_evtFilterSvc->getTBegin(iPar) ) {
72 //keep = true by default
73 break;
74 }
75 else if ( dtEts < m_evtFilterSvc->getTEnd(iPar) ) {
76 keep = false;
77 break;
78 }
79 }
80 }
81 /// filter with ets
82 if ( keep && iPar < npar ) {
83 double tEts = eventHeader->etsT1() / double(2000000.); //in second
84 for ( ; iPar < npar; ++iPar ) {
85 if ( m_evtFilterSvc->getFlag(iPar) == 0 ) {
86 continue;
87 }
88 if ( tEts < m_evtFilterSvc->getTBegin(iPar) ) {
89 //keep = true by default
90 break;
91 }
92 else if ( tEts < m_evtFilterSvc->getTEnd(iPar) ) {
93 keep = false;
94 break;
95 }
96 }
97 }
98
99 if ( keep ) {
100 // this is a good event, nothing to do
101 return StatusCode::SUCCESS;
102 }
103
104 // Otherwise, this is a bad event ...
105 // We register empty data objects without any hits to the Gaudi EDS
106
107 {
108 DigiEvent *digi = new DigiEvent();
109 digi->initialize(false); //not from MC
110 m_dataSvc->registerObject(EventModel::Digi::Event, digi);
111 }
112
113 {
114 DstEvent* dst = new DstEvent();
115 m_dataSvc->registerObject(EventModel::Dst::Event, dst);
116 }
117
118 {
119 TrigEvent * trig = new TrigEvent();
120 trig->initialize(false); //not from MC
121 m_dataSvc->registerObject(EventModel::Trig::Event, trig);
122 TrigData* trigData = new TrigData();
123 m_dataSvc->registerObject(EventModel::Trig::TrigData, trigData);
124 }
125
126 {
127 EvtRecObject* evtRecObject = new EvtRecObject();
128 m_dataSvc->registerObject(EventModel::EvtRec::Event, evtRecObject);
129 }
130
131 {
132 HltEvent * hlt = new HltEvent();
133 hlt->initialize(false); //not from MC
134 m_dataSvc->registerObject(EventModel::Hlt::Event, hlt);
135 DstHltInf* dstHltInf = new DstHltInf();
136 m_dataSvc->registerObject(EventModel::Hlt::DstHltInf, dstHltInf);
137 }
138
139 {
140 ReconEvent * recon = new ReconEvent();
141 m_dataSvc->registerObject(EventModel::Recon::Event, recon);
142 }
143
144 debug() << "event " << eventHeader->eventNumber() << " is passed" << endmsg;
145 m_incidentSvc->fireIncident(Incident(name(), IncidentType::AbortEvent));
146
147 return StatusCode::SUCCESS;
148}
149
150//=============================================================================
151// Finalize
152//=============================================================================
154
155 debug() << "==> Finalize" << endmsg;
156
157 return GaudiAlgorithm::finalize(); // must be called after all other actions
158}
DECLARE_ALGORITHM_FACTORY(ReadRawData)
void initialize(bool fromMc)
Definition: DigiEvent.h:30
void initialize(bool fromMc)
Definition: HltEvent.h:13
virtual int getFlag(unsigned int parId) const =0
virtual int getNpar() const =0
virtual StatusCode execute()
Algorithm execution.
virtual StatusCode initialize()
Algorithm initialization.
virtual StatusCode finalize()
Algorithm finalization.
virtual ~OfflineEvtFilterAlg()
Destructor.
void initialize(bool fromMc)
Definition: TrigEvent.h:13
_EXTERN_ std::string Event
Definition: EventModel.h:56
_EXTERN_ std::string Event
Definition: EventModel.h:128
_EXTERN_ std::string Event
Definition: EventModel.h:115
_EXTERN_ std::string Event
Definition: EventModel.h:72
_EXTERN_ std::string DstHltInf
Definition: EventModel.h:75
_EXTERN_ std::string Event
Definition: EventModel.h:84
_EXTERN_ std::string TrigData
Definition: EventModel.h:68
_EXTERN_ std::string Event
Definition: EventModel.h:66