CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
LhcTrackAnalyzer Class Reference

#include <MySub/LhcTrackAnalyzer/src/LhcTrackAnalyzer.cc>

Inheritance diagram for LhcTrackAnalyzer:
edm::EDAnalyzer

Public Member Functions

 LhcTrackAnalyzer (const edm::ParameterSet &)
 
 ~LhcTrackAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

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.

Constructor & Destructor Documentation

LhcTrackAnalyzer::LhcTrackAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 63 of file LhcTrackAnalyzer.cc.

References debug_, filename_, edm::ParameterSet::getParameter(), PVtxCollectionTag_, and TrackCollectionTag_.

65 {
66  //now do what ever initialization is needed
67  debug_ = iConfig.getParameter<bool> ("Debug");
68  TrackCollectionTag_ = iConfig.getParameter<edm::InputTag>("TrackCollectionTag");
69  PVtxCollectionTag_ = iConfig.getParameter<edm::InputTag>("PVtxCollectionTag");
70  filename_ = iConfig.getParameter<std::string>("OutputFileName");
71 }
T getParameter(std::string const &) const
edm::InputTag TrackCollectionTag_
std::string filename_
edm::InputTag PVtxCollectionTag_
LhcTrackAnalyzer::~LhcTrackAnalyzer ( )

Definition at line 74 of file LhcTrackAnalyzer.cc.

75 {
76 
77  // do anything here that needs to be done at desctruction time
78  // (e.g. close files, deallocate resources etc.)
79 
80 }

Member Function Documentation

void LhcTrackAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

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_offlineAnalysis_common_cff::reco, rootTree_, edm::EventID::run(), run_, SetVarToZero(), reco::TrackBase::tight, ExpressReco_HICollisions_FallBack::track, TrackCollectionTag_, trkAlgo_, trkQuality_, reco::TrackBase::undefAlgorithm, reco::TrackBase::undefQuality, validhits_, xPCA_, yPCA_, and zPCA_.

90 {
91  using namespace edm;
92  using namespace reco;
93  using namespace std;
94 
95  //=======================================================
96  // Initialize Root-tuple variables
97  //=======================================================
98 
99  SetVarToZero();
100 
101  //=======================================================
102  // Retrieve the Track information
103  //=======================================================
104 
105  Handle< TrackCollection> trackCollectionHandle;
106  iEvent.getByLabel(TrackCollectionTag_, trackCollectionHandle);
107  Handle<VertexCollection> vertexCollectionHandle;
108  iEvent.getByLabel(PVtxCollectionTag_, vertexCollectionHandle);
109  for(VertexCollection::const_iterator vtx = vertexCollectionHandle->begin();vtx!=vertexCollectionHandle->end(); ++vtx)
110  {
111  if(vtx==vertexCollectionHandle->begin()){
112  if(vtx->isFake())goodvtx_=false;
113  else goodvtx_=true;
114  }
115  else break;
116  }
117 
118 
119 
120  goodbx_=true;
121  // int bx = iEvent.bunchCrossing();
122  //if (bx==51 || bx==2724) goodbx_=true;
123 
124 
125 
126  run_=iEvent.id().run();
127  event_=iEvent.id().event();
128 
129  if(debug_)
130  cout<<"LhcTrackAnalyzer::analyze() looping over "<< trackCollectionHandle->size()<< "tracks." << endl;
131 
132  // unsigned int i = 0;
133  bool toomanytracks=false;
134  for(TrackCollection::const_iterator track = trackCollectionHandle->begin(); track!= trackCollectionHandle->end(); ++track)
135  {
136  //if(!toomanytracks){
137  if ( nTracks_ >= nMaxtracks_ ) {
138  std::cout << " LhcTrackAnalyzer::analyze() : Warning - Run "<< run_<<" Event "<< event_<<"\tNumber of tracks: " << trackCollectionHandle->size()<< " , greater than " << nMaxtracks_ << std::endl;
139  toomanytracks=true;
140  continue;
141 
142  }
143  // else{
144  pt_[nTracks_] = track->pt();
145  eta_[nTracks_] = track->eta();
146  phi_[nTracks_] = track->phi();
147  chi2_[nTracks_] = track->chi2();
148  chi2ndof_[nTracks_] = track->normalizedChi2();
149  charge_[nTracks_] = track->charge();
150  qoverp_[nTracks_] = track->qoverp();
151  dz_[nTracks_] = track->dz();
152  dxy_[nTracks_] = track->dxy();
153  xPCA_[nTracks_] = track->vertex().x();
154  yPCA_[nTracks_] = track->vertex().y();
155  zPCA_[nTracks_] = track->vertex().z();
156  validhits_[nTracks_][0]=track->numberOfValidHits();
157  validhits_[nTracks_][1]=track->hitPattern().numberOfValidPixelBarrelHits();
158  validhits_[nTracks_][2]=track->hitPattern().numberOfValidPixelEndcapHits();
159  validhits_[nTracks_][3]=track->hitPattern().numberOfValidStripTIBHits();
160  validhits_[nTracks_][4]=track->hitPattern().numberOfValidStripTIDHits();
161  validhits_[nTracks_][5]=track->hitPattern().numberOfValidStripTOBHits();
162  validhits_[nTracks_][6]=track->hitPattern().numberOfValidStripTECHits();
163 
164 
165 
166  int myalgo=-88;
167  if(track->algo()==reco::TrackBase::undefAlgorithm)myalgo=0;
168  if(track->algo()==reco::TrackBase::ctf)myalgo=1;
169  if(track->algo()==reco::TrackBase::iter0)myalgo=4;
170  if(track->algo()==reco::TrackBase::iter1)myalgo=5;
171  if(track->algo()==reco::TrackBase::iter2)myalgo=6;
172  if(track->algo()==reco::TrackBase::iter3)myalgo=7;
173  if(track->algo()==reco::TrackBase::iter4)myalgo=8;
174  if(track->algo()==reco::TrackBase::iter5)myalgo=9;
175  if(track->algo()==reco::TrackBase::iter6)myalgo=10;
176  if(track->algo()==reco::TrackBase::iter7)myalgo=11;
177  trkAlgo_[nTracks_] = myalgo;
178 
179  int myquality=-99;
180  if(track->quality(reco::TrackBase::undefQuality))myquality=-1;
181  if(track->quality(reco::TrackBase::loose))myquality=0;
182  if(track->quality(reco::TrackBase::tight))myquality=1;
183  if(track->quality(reco::TrackBase::highPurity))myquality=2;
184  //if(track->quality(reco::TrackBase::confirmed))myquality=3;
185  // if(track->quality(reco::TrackBase::goodIterative))myquality=4;
186  // if(track->quality(reco::TrackBase::qualitySize))myquality=5;
187  trkQuality_[nTracks_]= myquality;
188 
190  else isHighPurity_[nTracks_]=0;
191  nTracks_++;
192 
193 
194 
195 
196  // }//end if not too many tracks
197 
198 
199 
200  }//end loop on tracks
201 
202  for(int d=0;d<nTracks_;++d){
203  if(abs(trkQuality_[d])>5)cout<<"MYQUALITY!!! " <<trkQuality_[d] <<" at track # "<<d<<"/"<< nTracks_<<endl;
204  }
205 
206 
207 
208 
209  rootTree_->Fill();
210 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
int validhits_[nMaxtracks_][7]
#define abs(x)
Definition: mlp_lapack.h:159
int isHighPurity_[nMaxtracks_]
double dz_[nMaxtracks_]
double zPCA_[nMaxtracks_]
edm::InputTag TrackCollectionTag_
int trkQuality_[nMaxtracks_]
double qoverp_[nMaxtracks_]
double eta_[nMaxtracks_]
double phi_[nMaxtracks_]
double chi2ndof_[nMaxtracks_]
double yPCA_[nMaxtracks_]
double dxy_[nMaxtracks_]
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int trkAlgo_[nMaxtracks_]
edm::InputTag PVtxCollectionTag_
double xPCA_[nMaxtracks_]
edm::EventID id() const
Definition: EventBase.h:56
static const int nMaxtracks_
double chi2_[nMaxtracks_]
int charge_[nMaxtracks_]
tuple cout
Definition: gather_cfg.py:41
double pt_[nMaxtracks_]
void LhcTrackAnalyzer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 214 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_.

215 {
216  edm::LogInfo("beginJob") << "Begin Job" << std::endl;
217  // Define TTree for output
218  rootFile_ = new TFile(filename_.c_str(),"recreate");
219  rootTree_ = new TTree("tree","Lhc Track tree");
220 
221  // Track Paramters
222  rootTree_->Branch("run",&run_,"run/I");
223  rootTree_->Branch("event",&event_,"event/I");
224  rootTree_->Branch("goodbx",&goodbx_,"goodbx/O");
225  rootTree_->Branch("goodvtx",&goodvtx_,"goodvtx/O");
226  rootTree_->Branch("nTracks",&nTracks_,"nTracks/I");
227  rootTree_->Branch("pt",&pt_,"pt[nTracks]/D");
228  rootTree_->Branch("eta",&eta_,"eta[nTracks]/D");
229  rootTree_->Branch("phi",&phi_,"phi[nTracks]/D");
230  rootTree_->Branch("chi2",&chi2_,"chi2[nTracks]/D");
231  rootTree_->Branch("chi2ndof",&chi2ndof_,"chi2ndof[nTracks]/D");
232  rootTree_->Branch("charge",&charge_,"charge[nTracks]/I");
233  rootTree_->Branch("qoverp",&qoverp_,"qoverp[nTracks]/D");
234  rootTree_->Branch("dz",&dz_,"dz[nTracks]/D");
235  rootTree_->Branch("dxy",&dxy_,"dxy[nTracks]/D");
236  rootTree_->Branch("xPCA",&xPCA_,"xPCA[nTracks]/D");
237  rootTree_->Branch("yPCA",&yPCA_,"yPCA[nTracks]/D");
238  rootTree_->Branch("zPCA",&zPCA_,"zPCA[nTracks]/D");
239  rootTree_->Branch("isHighPurity",&isHighPurity_,"isHighPurity[nTracks]/I");
240  rootTree_->Branch("trkQuality",&trkQuality_,"trkQuality[nTracks]/I");
241  rootTree_->Branch("trkAlgo",&trkAlgo_,"trkAlgo[nTracks]/I");
242  rootTree_->Branch("nValidHits",&validhits_,"nValidHits[nTracks][7]/I");
243 
244 
245 }
int validhits_[nMaxtracks_][7]
int isHighPurity_[nMaxtracks_]
double dz_[nMaxtracks_]
double zPCA_[nMaxtracks_]
int trkQuality_[nMaxtracks_]
double qoverp_[nMaxtracks_]
double eta_[nMaxtracks_]
std::string filename_
double phi_[nMaxtracks_]
double chi2ndof_[nMaxtracks_]
double yPCA_[nMaxtracks_]
double dxy_[nMaxtracks_]
int trkAlgo_[nMaxtracks_]
double xPCA_[nMaxtracks_]
double chi2_[nMaxtracks_]
int charge_[nMaxtracks_]
double pt_[nMaxtracks_]
void LhcTrackAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 248 of file LhcTrackAnalyzer.cc.

References rootFile_.

249 {
250  if ( rootFile_ ) {
251  rootFile_->Write();
252  rootFile_->Close();
253  }
254 
255 
256 
257 }
void LhcTrackAnalyzer::SetVarToZero ( )
private

Definition at line 259 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().

259  {
260  run_=-1;
261  event_=-99;
262  nTracks_ = 0;
263  for ( int i=0; i<nMaxtracks_; ++i ) {
264  pt_[i] = 0;
265  eta_[i] = 0;
266  phi_[i] = 0;
267  chi2_[i] = 0;
268  chi2ndof_[i] = 0;
269  charge_[i] = 0;
270  qoverp_[i] = 0;
271  dz_[i] = 0;
272  dxy_[i] = 0;
273  xPCA_[i] = 0;
274  yPCA_[i] = 0;
275  zPCA_[i] = 0;
276  trkQuality_[i] = 0;
277  trkAlgo_[i] = -1;
278  isHighPurity_[i]=-3;
279  for(int j=0;j<7;j++){
280  validhits_[nTracks_][j]=-1*j;
281  }
282  }
283 
284 
285 }
int i
Definition: DBlmapReader.cc:9
int validhits_[nMaxtracks_][7]
int isHighPurity_[nMaxtracks_]
double dz_[nMaxtracks_]
double zPCA_[nMaxtracks_]
int trkQuality_[nMaxtracks_]
double qoverp_[nMaxtracks_]
double eta_[nMaxtracks_]
double phi_[nMaxtracks_]
double chi2ndof_[nMaxtracks_]
double yPCA_[nMaxtracks_]
int j
Definition: DBlmapReader.cc:9
double dxy_[nMaxtracks_]
int trkAlgo_[nMaxtracks_]
double xPCA_[nMaxtracks_]
static const int nMaxtracks_
double chi2_[nMaxtracks_]
int charge_[nMaxtracks_]
double pt_[nMaxtracks_]

Member Data Documentation

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
staticprivate

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().

edm::InputTag LhcTrackAnalyzer::PVtxCollectionTag_
private

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().

edm::InputTag LhcTrackAnalyzer::TrackCollectionTag_
private

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().