BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BbEmc Class Reference

#include <BbEmc.h>

Inheritance diagram for BbEmc:

Public Member Functions

 BbEmc (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()

Detailed Description

Definition at line 6 of file BbEmc.h.

Constructor & Destructor Documentation

◆ BbEmc()

BbEmc::BbEmc ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 52 of file BbEmc.cxx.

53 : Algorithm( name, pSvcLocator ) {
54 // Declare the properties
55 // control flag
56 declareProperty( "hist", m_hist = false );
57 declareProperty( "Trigger", m_trigger_flag = true );
58 declareProperty( "Hlt", m_hlt_flag = true );
59 declareProperty( "Estime", m_est_flag = true );
60 // RecMdcKalTrack or RecMdcTrack
61 declareProperty( "KalTrk", m_kalTrk_flag = true );
62 // Good shower selection cut
63 declareProperty( "EneCut", m_energy_cut = 1.2 );
64 declareProperty( "MomCut", m_mom_cut = 0.04 );
65 declareProperty( "DangCut", m_dangCut = 2.5 );
66 // Mdc Track vertex cut
67 declareProperty( "Vr0cut", m_vr0cut = 1.0 );
68 declareProperty( "Vz0cut", m_vz0cut = 5.0 );
69}

Referenced by BbEmc().

Member Function Documentation

◆ execute()

StatusCode BbEmc::execute ( )

Definition at line 126 of file BbEmc.cxx.

126 {
127
128 MsgStream log( msgSvc(), name() );
129 log << MSG::INFO << "in execute()" << endmsg;
130 m_cout_all++;
131
132 // save the events passed selection to a new file
133 setFilterPassed( false );
134
135 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
136 int runNum = eventHeader->runNumber();
137 int eventNum = eventHeader->eventNumber();
138 if ( m_cout_all % 1000 == 0 )
139 { std::cout << name() << "::" << m_cout_all << " events executed" << std::endl; }
140
141 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), "/Event/EvtRec/EvtRecEvent" );
142 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
143 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
144
145 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), "/Event/EvtRec/EvtRecTrackCol" );
146 if ( ( evtRecEvent->totalTracks() < 2 ) || ( evtRecEvent->totalTracks() > 30 ) )
147 { return StatusCode::SUCCESS; }
149
150 // High level trigger
151 int hlt_type = 0;
152 if ( m_hlt_flag )
153 {
154 SmartDataPtr<HltInf> hlt( eventSvc(), "/Event/Hlt/HltInf" );
155 DstHltInf* aHlt;
156 if ( !hlt )
157 {
158 log << MSG::WARNING << "Could not find Event HltInf, try DstHltInf now" << endmsg;
159 SmartDataPtr<DstHltInf> hltDst( eventSvc(), "/Event/Hlt/DstHltInf" );
160 if ( !hltDst )
161 {
162 log << MSG::ERROR << "Could not find Event DstHltInf too, please re-generate data"
163 << endmsg;
164 return StatusCode::FAILURE;
165 }
166 else { aHlt = hltDst; }
167 }
168 else { aHlt = hlt; }
169 uint32_t temp_type( aHlt->getEventType() );
170 int mask( 1 );
171 for ( int i = 0; i < 32; i++ )
172 {
173 if ( temp_type & mask )
174 {
175 hlt_type = i;
176 break;
177 }
178 temp_type >>= 1;
179 }
180 }
181
182 // Trigger
183 SmartDataPtr<TrigData> trigData( eventSvc(), "/Event/Trig/TrigData" );
184 if ( m_trigger_flag & runNum > 0 )
185 {
186 if ( !trigData )
187 {
188 log << MSG::FATAL << "Could not find TrigData in TDS" << endmsg;
189 return StatusCode::FAILURE;
190 }
191 // Print trigger information once:
192 log << MSG::DEBUG << "Trigger conditions: " << endmsg;
193 for ( int trig_id = 0; trig_id < 48; trig_id++ )
194 {
195 log << MSG::DEBUG << "i:" << trig_id << " name:" << trigData->getTrigCondName( trig_id )
196 << " cond:" << trigData->getTrigCondition( trig_id ) << endmsg;
197 }
198 }
199
200 // Event start time
201 SmartDataPtr<RecEsTimeCol> recEstimeCol( eventSvc(), "/Event/Recon/RecEsTimeCol" );
202 if ( m_est_flag & runNum > 0 )
203 {
204 if ( !recEstimeCol )
205 {
206 log << MSG::WARNING << "Can not get RecEsTimeCol" << endmsg;
207 return StatusCode::SUCCESS;
208 }
209 log << MSG::DEBUG << "size of EsTime: " << recEstimeCol->size() << endmsg;
210 }
211
212 // good shower selection
213 Vp4 vGood;
214 HepLorentzVector m_lv_ele;
215 for ( int i = 0; i < evtRecEvent->totalTracks(); i++ )
216 {
217 if ( i >= evtRecTrkCol->size() ) break;
218
219 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
220 if ( !( *itTrk )->isEmcShowerValid() ) continue;
221
222 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
223 if ( emcTrk->energy() < m_energy_cut ) continue;
224
225 Hep3Vector emcpos( emcTrk->x(), emcTrk->y(), emcTrk->z() );
226 m_lv_ele.setVect( emcpos );
227 m_lv_ele.setE( emcTrk->energy() );
228 vGood.push_back( m_lv_ele );
229 }
230
231 // num of good showers = 2
232 if ( vGood.size() - 2 ) return StatusCode::SUCCESS;
233 m_cout_good++;
234
235 // angle between two showers
236 double dang = vGood[0].vect().angle( vGood[1].vect() );
237 if ( dang < m_dangCut ) return StatusCode::SUCCESS;
238 m_cout_dang++;
239
240 if ( vGood[0].e() > vGood[1].e() ) swap( vGood[0], vGood[1] );
241
242 // check x0, y0, z0, r0
243 // suggest cut: |z0|<5 && r0<1 (cm)
244 double d0, z0, cosTheta, phi, mom;
245 Vint iGood;
246 iGood.clear();
247 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
248 {
249 double m_vz, m_vr;
251 if ( m_kalTrk_flag )
252 {
253 itTrk = evtRecTrkCol->begin() + i;
254 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
255 RecMdcKalTrack* mdcTrk = ( *itTrk )->mdcKalTrack();
256 m_vz = mdcTrk->z();
257 m_vr = mdcTrk->r();
258 }
259 else
260 {
261 if ( !( *itTrk )->isMdcTrackValid() ) continue;
262 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
263 m_vz = mdcTrk->z();
264 m_vr = mdcTrk->r();
265 }
266 if ( fabs( m_vz ) >= m_vz0cut ) continue;
267 if ( m_vr >= m_vr0cut ) continue;
268 iGood.push_back( i );
269 }
270
271 if ( m_hist )
272 {
273 m_run = runNum;
274 m_event = eventNum;
275
276 m_num_Ctrk = evtRecEvent->totalCharged();
277 m_num_Ntrk = evtRecEvent->totalNeutral();
278 m_num_Gtrk = iGood.size();
279 if ( trigData )
280 {
281 for ( int trig_id = 0; trig_id < 48; trig_id++ )
282 {
283 m_trig_index = trig_id;
284 if ( m_trig_index < 16 )
285 { m_trig_chan[m_trig_index] = trigData->getTrigChannel( m_trig_index ); }
286 m_trig_cond[m_trig_index] = trigData->getTrigCondition( m_trig_index );
287 }
288 m_trig_timewindow = trigData->getTimeWindow();
289 m_trig_timetype = trigData->getTimingType();
290 }
291
292 m_hlt_type = hlt_type;
293
294 if ( recEstimeCol )
295 {
296 m_est_start = ( *( recEstimeCol->begin() ) )->getTest();
297 m_est_status = ( *( recEstimeCol->begin() ) )->getStat();
298 m_est_quality = ( *( recEstimeCol->begin() ) )->getQuality();
299 }
300
301 m_dang = dang;
302 for ( int i = 0; i < 2; i++ )
303 {
304 m_index = i;
305 m_theta[m_index] = vGood[m_index].vect().theta();
306 m_phi[m_index] = vGood[m_index].vect().phi();
307 m_ene[m_index] = vGood[m_index].e();
308 }
309
310 m_tuple1->write();
311 }
312
313 setFilterPassed( true );
314
315 return StatusCode::SUCCESS;
316}
static long m_cout_good(0)
static long m_cout_tracks(0)
static long m_cout_dang(0)
EvtRecTrackCol::iterator EvtRecTrackIterator
void swap(DataList< T > lhs, DataList< T > rhs)
std::vector< HepLorentzVector > Vp4
Definition Gam4pikp.cxx:38
std::vector< int > Vint
Definition Gam4pikp.cxx:37
IMessageSvc * msgSvc()

◆ finalize()

StatusCode BbEmc::finalize ( )

Definition at line 318 of file BbEmc.cxx.

318 {
319 MsgStream log( msgSvc(), name() );
320 log << MSG::INFO << "in finalize()" << endmsg;
321
322 std::cout << name() << " total event: " << m_cout_all << std::endl;
323 std::cout << name() << " total tracks >= 2, <= 30: " << m_cout_tracks << std::endl;
324 std::cout << name() << " good showers = 2: " << m_cout_good << std::endl;
325 std::cout << name() << " angle between two showers: " << m_cout_dang << std::endl;
326
327 return StatusCode::SUCCESS;
328}

◆ initialize()

StatusCode BbEmc::initialize ( )

Definition at line 72 of file BbEmc.cxx.

72 {
73 MsgStream log( msgSvc(), name() );
74 log << MSG::INFO << "in initialize()" << endmsg;
75
76 StatusCode status;
77
78 if ( m_hist )
79 {
80 NTuplePtr nt1( ntupleSvc(), "FILEBbEmc/bbEmc" );
81 if ( nt1 ) m_tuple1 = nt1;
82 else
83 {
84 m_tuple1 = ntupleSvc()->book( "FILEBbEmc/bbEmc", CLID_ColumnWiseTuple,
85 "BbEmc N-Tuple example" );
86 if ( m_tuple1 )
87 {
88 status = m_tuple1->addItem( "run", m_run );
89 status = m_tuple1->addItem( "event", m_event );
90 status = m_tuple1->addItem( "numCtrk", m_num_Ctrk );
91 status = m_tuple1->addItem( "numNtrk", m_num_Ntrk );
92 status = m_tuple1->addItem( "numGtrk", m_num_Gtrk );
93 // trigger and hlt
94 status = m_tuple1->addItem( "trigindex", m_trig_index, 0, 48 );
95 status = m_tuple1->addIndexedItem( "trigcond", m_trig_index, m_trig_cond );
96 status = m_tuple1->addIndexedItem( "trigchan", m_trig_index, m_trig_chan );
97 status = m_tuple1->addItem( "timewindow", m_trig_timewindow );
98 status = m_tuple1->addItem( "timetype", m_trig_timetype );
99 status = m_tuple1->addItem( "hlttype", m_hlt_type );
100 // estime
101 status = m_tuple1->addItem( "estime", m_est_start );
102 status = m_tuple1->addItem( "status", m_est_status );
103 status = m_tuple1->addItem( "quality", m_est_quality );
104 // Emc shower
105 status = m_tuple1->addItem( "dang", m_dang );
106 status = m_tuple1->addItem( "index", m_index, 0, 2 );
107 status = m_tuple1->addIndexedItem( "theta", m_index, m_theta );
108 status = m_tuple1->addIndexedItem( "phi", m_index, m_phi );
109 status = m_tuple1->addIndexedItem( "ene", m_index, m_ene );
110 }
111 else
112 {
113 log << MSG::ERROR << "Cannot book N-tuple theone" << endmsg;
114 return StatusCode::FAILURE;
115 }
116 }
117
118 log << MSG::INFO << "end initialize()" << endmsg;
119 // finish book
120 } // end of m_hist
121
122 return StatusCode::SUCCESS;
123}
INTupleSvc * ntupleSvc()

The documentation for this class was generated from the following files: