BbEmc Class Reference

#include <BbEmc.h>

List of all members.

Public Member Functions

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

Private Attributes

bool m_hist
bool m_trigger_flag
bool m_hlt_flag
bool m_est_flag
bool m_kalTrk_flag
double m_energy_cut
double m_mom_cut
double m_dangCut
double m_vr0cut
double m_vz0cut
NTuple::Tuple * m_tuple1
NTuple::Item< long > m_run
NTuple::Item< long > m_event
NTuple::Item< long > m_num_Ctrk
NTuple::Item< long > m_num_Ntrk
NTuple::Item< long > m_num_Gtrk
NTuple::Item< long > m_index
NTuple::Array< double > m_ene
NTuple::Array< double > m_theta
NTuple::Array< double > m_phi
NTuple::Item< double > m_dang
NTuple::Item< long > m_trig_index
NTuple::Array< long > m_trig_cond
NTuple::Array< long > m_trig_chan
NTuple::Item< long > m_trig_timewindow
NTuple::Item< long > m_trig_timetype
NTuple::Item< double > m_est_start
NTuple::Item< long > m_est_status
NTuple::Item< double > m_est_quality
NTuple::Item< long > m_hlt_type


Detailed Description

Definition at line 6 of file BbEmc.h.


Constructor & Destructor Documentation

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

Definition at line 52 of file BbEmc.cxx.

References m_dangCut, m_energy_cut, m_est_flag, m_hist, m_hlt_flag, m_kalTrk_flag, m_mom_cut, m_trigger_flag, m_vr0cut, and m_vz0cut.

00052                                                             :
00053   Algorithm(name, pSvcLocator) {  
00054     //Declare the properties 
00055     //control flag
00056     declareProperty("hist",    m_hist=false);
00057     declareProperty("Trigger", m_trigger_flag=true);
00058     declareProperty("Hlt",     m_hlt_flag=true);
00059     declareProperty("Estime",  m_est_flag=true);
00060     //RecMdcKalTrack or RecMdcTrack
00061     declareProperty("KalTrk",  m_kalTrk_flag=true);
00062     //Good shower selection cut
00063     declareProperty("EneCut",  m_energy_cut=1.2);
00064     declareProperty("MomCut",  m_mom_cut=0.04);
00065     declareProperty("DangCut", m_dangCut= 2.5);
00066     //Mdc Track vertex cut
00067     declareProperty("Vr0cut",  m_vr0cut=1.0);
00068     declareProperty("Vz0cut",  m_vz0cut=5.0);
00069   }


Member Function Documentation

StatusCode BbEmc::execute (  ) 

Definition at line 121 of file BbEmc.cxx.

References Bes_Common::DEBUG, DstEmcShower::energy(), calibUtil::ERROR, Bes_Common::FATAL, DstHltInf::getEventType(), genRecEmupikp::i, Bes_Common::INFO, m_cout_all(), m_cout_dang(), m_cout_good(), m_cout_tracks(), m_dang, m_dangCut, m_ene, m_energy_cut, m_est_flag, m_est_quality, m_est_start, m_est_status, m_event, m_hist, m_hlt_flag, m_hlt_type, m_index, m_kalTrk_flag, m_num_Ctrk, m_num_Gtrk, m_num_Ntrk, m_phi, m_run, m_theta, m_trig_chan, m_trig_cond, m_trig_index, m_trig_timetype, m_trig_timewindow, m_trigger_flag, m_tuple1, m_vr0cut, m_vz0cut, msgSvc(), DstMdcTrack::r(), DstMdcKalTrack::r(), swap, Bes_Common::WARNING, DstEmcShower::x(), DstEmcShower::y(), DstMdcTrack::z(), DstMdcKalTrack::z(), and DstEmcShower::z().

00121                          {
00122 
00123   MsgStream log(msgSvc(),name());
00124   log<<MSG::INFO<<"in execute()"<<endreq;
00125   m_cout_all++;
00126 
00127   // save the events passed selection to a new file
00128   setFilterPassed(false);
00129 
00130   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00131   int runNum= eventHeader->runNumber();
00132   int eventNum= eventHeader->eventNumber();
00133   if(m_cout_all %1000 ==0) {
00134     std::cout<<name()<<"::"<< m_cout_all <<" events executed"<<std::endl;
00135   }
00136 
00137   SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), "/Event/EvtRec/EvtRecEvent");
00138   log << MSG::DEBUG <<"ncharg, nneu, tottks = "
00139     << evtRecEvent->totalCharged() << " , "
00140     << evtRecEvent->totalNeutral() << " , "
00141     << evtRecEvent->totalTracks() <<endreq;
00142 
00143   SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(),"/Event/EvtRec/EvtRecTrackCol");
00144   if((evtRecEvent->totalTracks()<2) || (evtRecEvent->totalTracks()>30)){
00145     return StatusCode::SUCCESS;
00146   }
00147   m_cout_tracks ++;
00148 
00149   // High level trigger
00150   int hlt_type=0;
00151   if(m_hlt_flag){
00152     SmartDataPtr<HltInf> hlt(eventSvc(),"/Event/Hlt/HltInf");
00153     DstHltInf *aHlt;
00154     if(!hlt) {
00155       log << MSG::WARNING << "Could not find Event HltInf, try DstHltInf now" << endreq;
00156       SmartDataPtr<DstHltInf> hltDst(eventSvc(),"/Event/Hlt/DstHltInf");
00157       if(!hltDst){
00158         log << MSG::ERROR << "Could not find Event DstHltInf too, please re-generate data" << endreq;
00159         return StatusCode::FAILURE;
00160       } else {
00161         aHlt=hltDst;
00162       }
00163     } else {
00164       aHlt=hlt;
00165     }
00166     uint32_t temp_type(aHlt->getEventType());
00167     int mask(1);
00168     for(int i=0; i<32; i++){
00169       if(temp_type & mask){
00170         hlt_type = i;
00171         break;
00172       }
00173       temp_type >>= 1;
00174     }
00175   }
00176   
00177   //Trigger 
00178   SmartDataPtr<TrigData> trigData(eventSvc(),"/Event/Trig/TrigData");
00179   if(m_trigger_flag & runNum>0){
00180     if (!trigData) {
00181       log << MSG::FATAL << "Could not find TrigData in TDS" << endreq;
00182       return StatusCode::FAILURE;
00183     }
00184     // Print trigger information once:
00185     log << MSG::DEBUG << "Trigger conditions: " << endreq;
00186     for(int trig_id=0; trig_id < 48; trig_id++){
00187       log << MSG::DEBUG << "i:" << trig_id 
00188         << "  name:" << trigData->getTrigCondName(trig_id)
00189         << "  cond:" << trigData->getTrigCondition(trig_id) << endreq;
00190     }
00191   }
00192 
00193   // Event start time
00194   SmartDataPtr<RecEsTimeCol> recEstimeCol(eventSvc(), "/Event/Recon/RecEsTimeCol");
00195   if(m_est_flag & runNum>0){
00196     if(!recEstimeCol){
00197       log << MSG::WARNING << "Can not get RecEsTimeCol" << endreq;
00198       return StatusCode::SUCCESS;
00199     }
00200     log << MSG::DEBUG <<"size of EsTime: " << recEstimeCol->size() << endreq;
00201   }
00202 
00203   // good shower selection
00204   Vp4 vGood;
00205   HepLorentzVector m_lv_ele;
00206   for(int i=0; i<evtRecEvent->totalTracks(); i++){
00207     if(i>=evtRecTrkCol->size()) break;
00208 
00209     EvtRecTrackIterator  itTrk=evtRecTrkCol->begin() + i;
00210     if(!(*itTrk)->isEmcShowerValid()) continue;
00211     
00212     RecEmcShower *emcTrk = (*itTrk)->emcShower();
00213     if(emcTrk->energy()<m_energy_cut) continue;
00214 
00215     Hep3Vector emcpos(emcTrk->x(), emcTrk->y(), emcTrk->z()); 
00216     m_lv_ele.setVect(emcpos);
00217     m_lv_ele.setE(emcTrk->energy());
00218     vGood.push_back(m_lv_ele);
00219   }
00220 
00221   // num of good showers = 2
00222   if(vGood.size() - 2) return SUCCESS; 
00223   m_cout_good ++;
00224 
00225   // angle between two showers 
00226   double dang = vGood[0].vect().angle(vGood[1].vect());
00227   if(dang < m_dangCut) return SUCCESS; 
00228   m_cout_dang ++;
00229 
00230   if(vGood[0].e() > vGood[1].e()) swap(vGood[0],vGood[1]);
00231 
00232   // check x0, y0, z0, r0
00233   // suggest cut: |z0|<5 && r0<1 (cm)
00234   double d0,z0,cosTheta,phi,mom;
00235   Vint iGood; iGood.clear();
00236   for(int i = 0; i < evtRecEvent->totalCharged(); i++){
00237     double m_vz,m_vr;
00238     EvtRecTrackIterator itTrk;
00239     if (m_kalTrk_flag){
00240       itTrk=evtRecTrkCol->begin() + i;
00241       if(!(*itTrk)->isMdcKalTrackValid()) continue;
00242       RecMdcKalTrack *mdcTrk = (*itTrk)->mdcKalTrack();
00243       m_vz = mdcTrk->z();
00244       m_vr = mdcTrk->r();
00245     }else{
00246       if(!(*itTrk)->isMdcTrackValid()) continue;
00247       RecMdcTrack *mdcTrk = (*itTrk)->mdcTrack();
00248       m_vz = mdcTrk->z();
00249       m_vr = mdcTrk->r();
00250     }
00251     if(fabs(m_vz) >= m_vz0cut) continue;
00252     if(m_vr >= m_vr0cut) continue;
00253     iGood.push_back(i);
00254   }
00255 
00256   if (m_hist){
00257     m_run = runNum;
00258     m_event = eventNum;
00259 
00260     m_num_Ctrk = evtRecEvent->totalCharged();
00261     m_num_Ntrk = evtRecEvent->totalNeutral();
00262     m_num_Gtrk = iGood.size();
00263     if (trigData){
00264       for(int trig_id=0; trig_id < 48; trig_id++){
00265         m_trig_index = trig_id;
00266         if(m_trig_index<16){
00267           m_trig_chan[m_trig_index] = trigData->getTrigChannel(m_trig_index);
00268         }
00269         m_trig_cond[m_trig_index] = trigData->getTrigCondition(m_trig_index);
00270       }
00271       m_trig_timewindow = trigData->getTimeWindow();
00272       m_trig_timetype = trigData->getTimingType();
00273     }
00274 
00275     m_hlt_type = hlt_type;
00276 
00277     if (recEstimeCol){
00278       m_est_start = (*(recEstimeCol->begin()))->getTest();
00279       m_est_status = (*(recEstimeCol->begin()))->getStat();
00280       m_est_quality = (*(recEstimeCol->begin()))->getQuality();
00281     }
00282 
00283     m_dang = dang;
00284     for(int i=0; i<2; i++){
00285       m_index = i;
00286       m_theta[m_index] = vGood[m_index].vect().theta();
00287       m_phi[m_index] = vGood[m_index].vect().phi();
00288       m_ene[m_index] = vGood[m_index].e();
00289     }
00290 
00291     m_tuple1->write();
00292   }
00293 
00294   setFilterPassed(true);
00295 
00296   return StatusCode::SUCCESS;
00297 }

StatusCode BbEmc::finalize (  ) 

Definition at line 299 of file BbEmc.cxx.

References Bes_Common::INFO, m_cout_all(), m_cout_dang(), m_cout_good(), m_cout_tracks(), and msgSvc().

00299                            {
00300   MsgStream log(msgSvc(),name());
00301   log<<MSG::INFO<<"in finalize()"<<endreq;
00302 
00303   std::cout <<name()<<" total event: "<< m_cout_all << std::endl;
00304   std::cout <<name()<<" total tracks >= 2, <= 30: "<<m_cout_tracks << std::endl;
00305   std::cout <<name()<<" good showers = 2: "<< m_cout_good << std::endl;
00306   std::cout <<name()<<" angle between two showers: "<< m_cout_dang << std::endl;
00307 
00308   return StatusCode::SUCCESS;
00309 }

StatusCode BbEmc::initialize (  ) 

Definition at line 72 of file BbEmc.cxx.

References calibUtil::ERROR, Bes_Common::INFO, m_dang, m_ene, m_est_quality, m_est_start, m_est_status, m_event, m_hist, m_hlt_type, m_index, m_num_Ctrk, m_num_Gtrk, m_num_Ntrk, m_phi, m_run, m_theta, m_trig_chan, m_trig_cond, m_trig_index, m_trig_timetype, m_trig_timewindow, m_tuple1, msgSvc(), and ntupleSvc().

00072                              {
00073   MsgStream log(msgSvc(), name());
00074   log << MSG::INFO << "in initialize()" << endmsg;
00075 
00076   StatusCode status;
00077 
00078   if(m_hist){
00079     NTuplePtr nt1(ntupleSvc(), "FILEBbEmc/bbEmc");
00080     if ( nt1 ) m_tuple1 = nt1;
00081     else {
00082       m_tuple1 = ntupleSvc()->book ("FILEBbEmc/bbEmc", CLID_ColumnWiseTuple, "BbEmc N-Tuple example");
00083       if ( m_tuple1 ){
00084         status = m_tuple1->addItem ("run",            m_run);
00085         status = m_tuple1->addItem ("event",          m_event);
00086         status = m_tuple1->addItem ("numCtrk",        m_num_Ctrk);
00087         status = m_tuple1->addItem ("numNtrk",        m_num_Ntrk);
00088         status = m_tuple1->addItem ("numGtrk",        m_num_Gtrk);
00089         //trigger and hlt
00090         status = m_tuple1->addItem ("trigindex",      m_trig_index, 0, 48);
00091         status = m_tuple1->addIndexedItem("trigcond", m_trig_index, m_trig_cond);
00092         status = m_tuple1->addIndexedItem("trigchan", m_trig_index, m_trig_chan);
00093         status = m_tuple1->addItem ("timewindow",     m_trig_timewindow);
00094         status = m_tuple1->addItem ("timetype",       m_trig_timetype);
00095         status = m_tuple1->addItem ("hlttype",        m_hlt_type );
00096         //estime
00097         status = m_tuple1->addItem ("estime",         m_est_start);
00098         status = m_tuple1->addItem ("status",         m_est_status);
00099         status = m_tuple1->addItem ("quality",        m_est_quality);
00100         //Emc shower 
00101         status = m_tuple1->addItem ("dang",           m_dang);
00102         status = m_tuple1->addItem ("index",          m_index,0,2);
00103         status = m_tuple1->addIndexedItem ("theta",   m_index, m_theta);
00104         status = m_tuple1->addIndexedItem ("phi",     m_index, m_phi);
00105         status = m_tuple1->addIndexedItem ("ene",     m_index, m_ene);
00106       } else { 
00107         log << MSG::ERROR << "Cannot book N-tuple theone"<<endmsg;
00108         return StatusCode::FAILURE;
00109       }
00110     }
00111 
00112     log << MSG::INFO << "end initialize()" << endmsg;
00113     // finish book
00114   }//end of m_hist
00115 
00116   return StatusCode::SUCCESS;
00117 
00118 }


Member Data Documentation

NTuple::Item<double> BbEmc::m_dang [private]

Definition at line 37 of file BbEmc.h.

Referenced by execute(), and initialize().

double BbEmc::m_dangCut [private]

Definition at line 23 of file BbEmc.h.

Referenced by BbEmc(), and execute().

NTuple::Array<double> BbEmc::m_ene [private]

Definition at line 34 of file BbEmc.h.

Referenced by execute(), and initialize().

double BbEmc::m_energy_cut [private]

Definition at line 21 of file BbEmc.h.

Referenced by BbEmc(), and execute().

bool BbEmc::m_est_flag [private]

Definition at line 18 of file BbEmc.h.

Referenced by BbEmc(), and execute().

NTuple::Item<double> BbEmc::m_est_quality [private]

Definition at line 47 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<double> BbEmc::m_est_start [private]

Definition at line 45 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_est_status [private]

Definition at line 46 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_event [private]

Definition at line 29 of file BbEmc.h.

Referenced by execute(), and initialize().

bool BbEmc::m_hist [private]

Definition at line 15 of file BbEmc.h.

Referenced by BbEmc(), execute(), and initialize().

bool BbEmc::m_hlt_flag [private]

Definition at line 17 of file BbEmc.h.

Referenced by BbEmc(), and execute().

NTuple::Item<long> BbEmc::m_hlt_type [private]

Definition at line 48 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_index [private]

Definition at line 33 of file BbEmc.h.

Referenced by execute(), and initialize().

bool BbEmc::m_kalTrk_flag [private]

Definition at line 19 of file BbEmc.h.

Referenced by BbEmc(), and execute().

double BbEmc::m_mom_cut [private]

Definition at line 22 of file BbEmc.h.

Referenced by BbEmc().

NTuple::Item<long> BbEmc::m_num_Ctrk [private]

Definition at line 30 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_num_Gtrk [private]

Definition at line 32 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_num_Ntrk [private]

Definition at line 31 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Array<double> BbEmc::m_phi [private]

Definition at line 36 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_run [private]

Definition at line 28 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Array<double> BbEmc::m_theta [private]

Definition at line 35 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Array<long> BbEmc::m_trig_chan [private]

Definition at line 41 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Array<long> BbEmc::m_trig_cond [private]

Definition at line 40 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_trig_index [private]

Definition at line 39 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_trig_timetype [private]

Definition at line 43 of file BbEmc.h.

Referenced by execute(), and initialize().

NTuple::Item<long> BbEmc::m_trig_timewindow [private]

Definition at line 42 of file BbEmc.h.

Referenced by execute(), and initialize().

bool BbEmc::m_trigger_flag [private]

Definition at line 16 of file BbEmc.h.

Referenced by BbEmc(), and execute().

NTuple::Tuple* BbEmc::m_tuple1 [private]

Definition at line 27 of file BbEmc.h.

Referenced by execute(), and initialize().

double BbEmc::m_vr0cut [private]

Definition at line 24 of file BbEmc.h.

Referenced by BbEmc(), and execute().

double BbEmc::m_vz0cut [private]

Definition at line 25 of file BbEmc.h.

Referenced by BbEmc(), and execute().


Generated on Tue Nov 29 23:17:27 2016 for BOSS_7.0.2 by  doxygen 1.4.7