CGEM BOSS 6.6.5.i
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.

52 :
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 }

Member Function Documentation

◆ execute()

StatusCode BbEmc::execute ( )

Definition at line 121 of file BbEmc.cxx.

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

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

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

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