BOSS 7.1.1
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 53 of file BbEmc.cxx.

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

Member Function Documentation

◆ execute()

StatusCode BbEmc::execute ( )

Definition at line 122 of file BbEmc.cxx.

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

◆ finalize()

StatusCode BbEmc::finalize ( )

Definition at line 300 of file BbEmc.cxx.

300 {
301 MsgStream log(msgSvc(),name());
302 log<<MSG::INFO<<"in finalize()"<<endreq;
303
304 std::cout <<name()<<" total event: "<< m_cout_all << std::endl;
305 std::cout <<name()<<" total tracks >= 2, <= 30: "<<m_cout_tracks << std::endl;
306 std::cout <<name()<<" good showers = 2: "<< m_cout_good << std::endl;
307 std::cout <<name()<<" angle between two showers: "<< m_cout_dang << std::endl;
308
309 return StatusCode::SUCCESS;
310}

◆ initialize()

StatusCode BbEmc::initialize ( )

Definition at line 73 of file BbEmc.cxx.

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

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