74 MsgStream log(
msgSvc(), name());
75 log << MSG::INFO <<
"in initialize()" << endmsg;
80 NTuplePtr nt1(
ntupleSvc(),
"FILEBbEmc/bbEmc");
81 if ( nt1 ) m_tuple1 = nt1;
83 m_tuple1 =
ntupleSvc()->book (
"FILEBbEmc/bbEmc", CLID_ColumnWiseTuple,
"BbEmc N-Tuple example");
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);
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 );
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);
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);
108 log << MSG::ERROR <<
"Cannot book N-tuple theone"<<endmsg;
109 return StatusCode::FAILURE;
113 log << MSG::INFO <<
"end initialize()" << endmsg;
117 return StatusCode::SUCCESS;
124 MsgStream log(
msgSvc(),name());
125 log<<MSG::INFO<<
"in execute()"<<endreq;
129 setFilterPassed(
false);
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;
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;
144 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(),
"/Event/EvtRec/EvtRecTrackCol");
145 if((evtRecEvent->totalTracks()<2) || (evtRecEvent->totalTracks()>30)){
146 return StatusCode::SUCCESS;
153 SmartDataPtr<HltInf> hlt(eventSvc(),
"/Event/Hlt/HltInf");
156 log << MSG::WARNING <<
"Could not find Event HltInf, try DstHltInf now" << endreq;
157 SmartDataPtr<DstHltInf> hltDst(eventSvc(),
"/Event/Hlt/DstHltInf");
159 log << MSG::ERROR <<
"Could not find Event DstHltInf too, please re-generate data" << endreq;
160 return StatusCode::FAILURE;
169 for(
int i=0; i<32; i++){
170 if(temp_type & mask){
179 SmartDataPtr<TrigData> trigData(eventSvc(),
"/Event/Trig/TrigData");
180 if(m_trigger_flag & runNum>0){
182 log << MSG::FATAL <<
"Could not find TrigData in TDS" << endreq;
183 return StatusCode::FAILURE;
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;
195 SmartDataPtr<RecEsTimeCol> recEstimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
196 if(m_est_flag & runNum>0){
198 log << MSG::WARNING <<
"Can not get RecEsTimeCol" << endreq;
199 return StatusCode::SUCCESS;
201 log << MSG::DEBUG <<
"size of EsTime: " << recEstimeCol->size() << endreq;
206 HepLorentzVector m_lv_ele;
207 for(
int i=0; i<evtRecEvent->totalTracks(); i++){
208 if(i>=evtRecTrkCol->size())
break;
211 if(!(*itTrk)->isEmcShowerValid())
continue;
214 if(emcTrk->
energy()<m_energy_cut)
continue;
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);
223 if(vGood.size() - 2)
return SUCCESS;
227 double dang = vGood[0].vect().angle(vGood[1].vect());
228 if(dang < m_dangCut)
return SUCCESS;
231 if(vGood[0].e() > vGood[1].e()) swap(vGood[0],vGood[1]);
235 double d0,z0,cosTheta,phi,mom;
236 Vint iGood; iGood.clear();
237 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
241 itTrk=evtRecTrkCol->begin() + i;
242 if(!(*itTrk)->isMdcKalTrackValid())
continue;
247 if(!(*itTrk)->isMdcTrackValid())
continue;
252 if(fabs(m_vz) >= m_vz0cut)
continue;
253 if(m_vr >= m_vr0cut)
continue;
261 m_num_Ctrk = evtRecEvent->totalCharged();
262 m_num_Ntrk = evtRecEvent->totalNeutral();
263 m_num_Gtrk = iGood.size();
265 for(
int trig_id=0; trig_id < 48; trig_id++){
266 m_trig_index = trig_id;
268 m_trig_chan[m_trig_index] = trigData->getTrigChannel(m_trig_index);
270 m_trig_cond[m_trig_index] = trigData->getTrigCondition(m_trig_index);
272 m_trig_timewindow = trigData->getTimeWindow();
273 m_trig_timetype = trigData->getTimingType();
276 m_hlt_type = hlt_type;
279 m_est_start = (*(recEstimeCol->begin()))->getTest();
280 m_est_status = (*(recEstimeCol->begin()))->getStat();
281 m_est_quality = (*(recEstimeCol->begin()))->getQuality();
285 for(
int i=0; i<2; 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();
295 setFilterPassed(
true);
297 return StatusCode::SUCCESS;