#include <MySub/LhcTrackAnalyzer/src/LhcTrackAnalyzer.cc>
Public Member Functions | |
LhcTrackAnalyzer (const edm::ParameterSet &) | |
~LhcTrackAnalyzer () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
void | SetVarToZero () |
Private Attributes | |
int | charge_ [nMaxtracks_] |
double | chi2_ [nMaxtracks_] |
double | chi2ndof_ [nMaxtracks_] |
bool | debug_ |
double | dxy_ [nMaxtracks_] |
double | dz_ [nMaxtracks_] |
double | eta_ [nMaxtracks_] |
int | event_ |
std::string | filename_ |
bool | goodbx_ |
bool | goodvtx_ |
int | isHighPurity_ [nMaxtracks_] |
int | nTracks_ |
double | phi_ [nMaxtracks_] |
double | pt_ [nMaxtracks_] |
edm::InputTag | PVtxCollectionTag_ |
double | qoverp_ [nMaxtracks_] |
TFile * | rootFile_ |
TTree * | rootTree_ |
int | run_ |
edm::InputTag | TrackCollectionTag_ |
int | trkAlgo_ [nMaxtracks_] |
int | trkQuality_ [nMaxtracks_] |
int | validhits_ [nMaxtracks_][7] |
double | xPCA_ [nMaxtracks_] |
double | yPCA_ [nMaxtracks_] |
double | zPCA_ [nMaxtracks_] |
Static Private Attributes | |
static const int | nMaxtracks_ = 3000 |
Originally written by M.Musich Expanded by A. Bonato
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 61 of file LhcTrackAnalyzer.h.
LhcTrackAnalyzer::LhcTrackAnalyzer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 63 of file LhcTrackAnalyzer.cc.
References debug_, filename_, edm::ParameterSet::getParameter(), PVtxCollectionTag_, and TrackCollectionTag_.
{ //now do what ever initialization is needed debug_ = iConfig.getParameter<bool> ("Debug"); TrackCollectionTag_ = iConfig.getParameter<edm::InputTag>("TrackCollectionTag"); PVtxCollectionTag_ = iConfig.getParameter<edm::InputTag>("PVtxCollectionTag"); filename_ = iConfig.getParameter<std::string>("OutputFileName"); }
LhcTrackAnalyzer::~LhcTrackAnalyzer | ( | ) |
Definition at line 74 of file LhcTrackAnalyzer.cc.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
void LhcTrackAnalyzer::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 89 of file LhcTrackAnalyzer.cc.
References abs, charge_, chi2_, chi2ndof_, gather_cfg::cout, reco::TrackBase::ctf, debug_, dxy_, dz_, eta_, edm::EventID::event(), event_, edm::Event::getByLabel(), goodbx_, goodvtx_, reco::TrackBase::highPurity, edm::EventBase::id(), isHighPurity_, reco::TrackBase::iter0, reco::TrackBase::iter1, reco::TrackBase::iter2, reco::TrackBase::iter3, reco::TrackBase::iter4, reco::TrackBase::iter5, reco::TrackBase::iter6, reco::TrackBase::iter7, reco::TrackBase::loose, nMaxtracks_, nTracks_, phi_, pt_, PVtxCollectionTag_, qoverp_, dt_dqm_sourceclient_common_cff::reco, rootTree_, edm::EventID::run(), run_, SetVarToZero(), reco::TrackBase::tight, TrackCollectionTag_, trkAlgo_, trkQuality_, reco::TrackBase::undefAlgorithm, reco::TrackBase::undefQuality, validhits_, xPCA_, yPCA_, and zPCA_.
{ using namespace edm; using namespace reco; using namespace std; //======================================================= // Initialize Root-tuple variables //======================================================= SetVarToZero(); //======================================================= // Retrieve the Track information //======================================================= Handle< TrackCollection> trackCollectionHandle; iEvent.getByLabel(TrackCollectionTag_, trackCollectionHandle); Handle<VertexCollection> vertexCollectionHandle; iEvent.getByLabel(PVtxCollectionTag_, vertexCollectionHandle); for(VertexCollection::const_iterator vtx = vertexCollectionHandle->begin();vtx!=vertexCollectionHandle->end(); ++vtx) { if(vtx==vertexCollectionHandle->begin()){ if(vtx->isFake())goodvtx_=false; else goodvtx_=true; } else break; } goodbx_=true; // int bx = iEvent.bunchCrossing(); //if (bx==51 || bx==2724) goodbx_=true; run_=iEvent.id().run(); event_=iEvent.id().event(); if(debug_) cout<<"LhcTrackAnalyzer::analyze() looping over "<< trackCollectionHandle->size()<< "tracks." << endl; // unsigned int i = 0; for(TrackCollection::const_iterator track = trackCollectionHandle->begin(); track!= trackCollectionHandle->end(); ++track) { if ( nTracks_ >= nMaxtracks_ ) { std::cout << " LhcTrackAnalyzer::analyze() : Warning - Run "<< run_<<" Event "<< event_<<"\tNumber of tracks: " << trackCollectionHandle->size()<< " , greater than " << nMaxtracks_ << std::endl; continue; } pt_[nTracks_] = track->pt(); eta_[nTracks_] = track->eta(); phi_[nTracks_] = track->phi(); chi2_[nTracks_] = track->chi2(); chi2ndof_[nTracks_] = track->normalizedChi2(); charge_[nTracks_] = track->charge(); qoverp_[nTracks_] = track->qoverp(); dz_[nTracks_] = track->dz(); dxy_[nTracks_] = track->dxy(); xPCA_[nTracks_] = track->vertex().x(); yPCA_[nTracks_] = track->vertex().y(); zPCA_[nTracks_] = track->vertex().z(); validhits_[nTracks_][0]=track->numberOfValidHits(); validhits_[nTracks_][1]=track->hitPattern().numberOfValidPixelBarrelHits(); validhits_[nTracks_][2]=track->hitPattern().numberOfValidPixelEndcapHits(); validhits_[nTracks_][3]=track->hitPattern().numberOfValidStripTIBHits(); validhits_[nTracks_][4]=track->hitPattern().numberOfValidStripTIDHits(); validhits_[nTracks_][5]=track->hitPattern().numberOfValidStripTOBHits(); validhits_[nTracks_][6]=track->hitPattern().numberOfValidStripTECHits(); int myalgo=-88; if(track->algo()==reco::TrackBase::undefAlgorithm)myalgo=0; if(track->algo()==reco::TrackBase::ctf)myalgo=1; if(track->algo()==reco::TrackBase::iter0)myalgo=4; if(track->algo()==reco::TrackBase::iter1)myalgo=5; if(track->algo()==reco::TrackBase::iter2)myalgo=6; if(track->algo()==reco::TrackBase::iter3)myalgo=7; if(track->algo()==reco::TrackBase::iter4)myalgo=8; if(track->algo()==reco::TrackBase::iter5)myalgo=9; if(track->algo()==reco::TrackBase::iter6)myalgo=10; if(track->algo()==reco::TrackBase::iter7)myalgo=11; trkAlgo_[nTracks_] = myalgo; int myquality=-99; if(track->quality(reco::TrackBase::undefQuality))myquality=-1; if(track->quality(reco::TrackBase::loose))myquality=0; if(track->quality(reco::TrackBase::tight))myquality=1; if(track->quality(reco::TrackBase::highPurity))myquality=2; //if(track->quality(reco::TrackBase::confirmed))myquality=3; // if(track->quality(reco::TrackBase::goodIterative))myquality=4; // if(track->quality(reco::TrackBase::qualitySize))myquality=5; trkQuality_[nTracks_]= myquality; if(track->quality(reco::TrackBase::highPurity))isHighPurity_[nTracks_]=1; else isHighPurity_[nTracks_]=0; nTracks_++; }//end loop on tracks for(int d=0;d<nTracks_;++d){ if(abs(trkQuality_[d])>5)cout<<"MYQUALITY!!! " <<trkQuality_[d] <<" at track # "<<d<<"/"<< nTracks_<<endl; } rootTree_->Fill(); }
void LhcTrackAnalyzer::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 207 of file LhcTrackAnalyzer.cc.
References charge_, chi2_, chi2ndof_, dxy_, dz_, eta_, event_, filename_, goodbx_, goodvtx_, isHighPurity_, nTracks_, phi_, pt_, qoverp_, rootFile_, rootTree_, run_, trkAlgo_, trkQuality_, validhits_, xPCA_, yPCA_, and zPCA_.
{ edm::LogInfo("beginJob") << "Begin Job" << std::endl; // Define TTree for output rootFile_ = new TFile(filename_.c_str(),"recreate"); rootTree_ = new TTree("tree","Lhc Track tree"); // Track Paramters rootTree_->Branch("run",&run_,"run/I"); rootTree_->Branch("event",&event_,"event/I"); rootTree_->Branch("goodbx",&goodbx_,"goodbx/O"); rootTree_->Branch("goodvtx",&goodvtx_,"goodvtx/O"); rootTree_->Branch("nTracks",&nTracks_,"nTracks/I"); rootTree_->Branch("pt",&pt_,"pt[nTracks]/D"); rootTree_->Branch("eta",&eta_,"eta[nTracks]/D"); rootTree_->Branch("phi",&phi_,"phi[nTracks]/D"); rootTree_->Branch("chi2",&chi2_,"chi2[nTracks]/D"); rootTree_->Branch("chi2ndof",&chi2ndof_,"chi2ndof[nTracks]/D"); rootTree_->Branch("charge",&charge_,"charge[nTracks]/I"); rootTree_->Branch("qoverp",&qoverp_,"qoverp[nTracks]/D"); rootTree_->Branch("dz",&dz_,"dz[nTracks]/D"); rootTree_->Branch("dxy",&dxy_,"dxy[nTracks]/D"); rootTree_->Branch("xPCA",&xPCA_,"xPCA[nTracks]/D"); rootTree_->Branch("yPCA",&yPCA_,"yPCA[nTracks]/D"); rootTree_->Branch("zPCA",&zPCA_,"zPCA[nTracks]/D"); rootTree_->Branch("isHighPurity",&isHighPurity_,"isHighPurity[nTracks]/I"); rootTree_->Branch("trkQuality",&trkQuality_,"trkQuality[nTracks]/I"); rootTree_->Branch("trkAlgo",&trkAlgo_,"trkAlgo[nTracks]/I"); rootTree_->Branch("nValidHits",&validhits_,"nValidHits[nTracks][7]/I"); }
void LhcTrackAnalyzer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 241 of file LhcTrackAnalyzer.cc.
References rootFile_.
void LhcTrackAnalyzer::SetVarToZero | ( | ) | [private] |
Definition at line 252 of file LhcTrackAnalyzer.cc.
References charge_, chi2_, chi2ndof_, dxy_, dz_, eta_, event_, i, isHighPurity_, j, nMaxtracks_, nTracks_, phi_, pt_, qoverp_, run_, trkAlgo_, trkQuality_, validhits_, xPCA_, yPCA_, and zPCA_.
Referenced by analyze().
{ run_=-1; event_=-99; nTracks_ = 0; for ( int i=0; i<nMaxtracks_; ++i ) { pt_[i] = 0; eta_[i] = 0; phi_[i] = 0; chi2_[i] = 0; chi2ndof_[i] = 0; charge_[i] = 0; qoverp_[i] = 0; dz_[i] = 0; dxy_[i] = 0; xPCA_[i] = 0; yPCA_[i] = 0; zPCA_[i] = 0; trkQuality_[i] = 0; trkAlgo_[i] = -1; isHighPurity_[i]=-3; for(int j=0;j<7;j++){ validhits_[nTracks_][j]=-1*j; } } }
int LhcTrackAnalyzer::charge_[nMaxtracks_] [private] |
Definition at line 95 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::chi2_[nMaxtracks_] [private] |
Definition at line 93 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::chi2ndof_[nMaxtracks_] [private] |
Definition at line 94 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
bool LhcTrackAnalyzer::debug_ [private] |
Definition at line 75 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and LhcTrackAnalyzer().
double LhcTrackAnalyzer::dxy_[nMaxtracks_] [private] |
Definition at line 98 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::dz_[nMaxtracks_] [private] |
Definition at line 97 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::eta_[nMaxtracks_] [private] |
Definition at line 91 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
int LhcTrackAnalyzer::event_ [private] |
Definition at line 89 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
std::string LhcTrackAnalyzer::filename_ [private] |
Definition at line 78 of file LhcTrackAnalyzer.h.
Referenced by beginJob(), and LhcTrackAnalyzer().
bool LhcTrackAnalyzer::goodbx_ [private] |
Definition at line 106 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and beginJob().
bool LhcTrackAnalyzer::goodvtx_ [private] |
Definition at line 107 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and beginJob().
int LhcTrackAnalyzer::isHighPurity_[nMaxtracks_] [private] |
Definition at line 104 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
const int LhcTrackAnalyzer::nMaxtracks_ = 3000 [static, private] |
Definition at line 86 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and SetVarToZero().
int LhcTrackAnalyzer::nTracks_ [private] |
Definition at line 87 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::phi_[nMaxtracks_] [private] |
Definition at line 92 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::pt_[nMaxtracks_] [private] |
Definition at line 90 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
Definition at line 74 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and LhcTrackAnalyzer().
double LhcTrackAnalyzer::qoverp_[nMaxtracks_] [private] |
Definition at line 96 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
TFile* LhcTrackAnalyzer::rootFile_ [private] |
Definition at line 79 of file LhcTrackAnalyzer.h.
Referenced by beginJob(), and endJob().
TTree* LhcTrackAnalyzer::rootTree_ [private] |
Definition at line 80 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and beginJob().
int LhcTrackAnalyzer::run_ [private] |
Definition at line 88 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
Definition at line 73 of file LhcTrackAnalyzer.h.
Referenced by analyze(), and LhcTrackAnalyzer().
int LhcTrackAnalyzer::trkAlgo_[nMaxtracks_] [private] |
Definition at line 102 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
int LhcTrackAnalyzer::trkQuality_[nMaxtracks_] [private] |
Definition at line 103 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
int LhcTrackAnalyzer::validhits_[nMaxtracks_][7] [private] |
Definition at line 105 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::xPCA_[nMaxtracks_] [private] |
Definition at line 99 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::yPCA_[nMaxtracks_] [private] |
Definition at line 100 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().
double LhcTrackAnalyzer::zPCA_[nMaxtracks_] [private] |
Definition at line 101 of file LhcTrackAnalyzer.h.
Referenced by analyze(), beginJob(), and SetVarToZero().