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