CMS 3D CMS Logo

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

#include <MultiTrackValidator.h>

Inheritance diagram for MultiTrackValidator:
edm::EDAnalyzer MultiTrackValidatorBase edm::EDConsumerBase MultiTrackValidatorGenPs

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Method called once per event. More...
 
void beginRun (edm::Run const &, edm::EventSetup const &)
 Method called before the event loop. More...
 
void endRun (edm::Run const &, edm::EventSetup const &)
 Method called at the end of the event loop. More...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidator ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

edm::InputTag associatormap
 
MTVHistoProducerAlgohistoProducerAlgo_
 
bool UseAssociators
 
- Protected Attributes inherited from MultiTrackValidatorBase
std::vector< const
TrackAssociatorBase * > 
associator
 
std::vector< std::string > associators
 
edm::InputTag bsSrc
 
DQMStoredbe_
 
bool ignoremissingtkcollection_
 
std::vector< edm::InputTaglabel
 
edm::InputTag label_pileupinfo
 
edm::InputTag label_tp_effic
 
edm::InputTag label_tp_fake
 
edm::InputTag label_tv
 
edm::InputTag m_dEdx1Tag
 
edm::InputTag m_dEdx2Tag
 
std::string out
 
std::string parametersDefiner
 
std::string sim
 
bool skipHistoFit
 
edm::ESHandle< MagneticFieldtheMF
 

Private Attributes

edm::InputTag _simHitTpMapTag
 
CosmicTrackingParticleSelector cosmictpSelector
 
std::string dirName_
 
bool runStandalone
 
TrackingParticleSelector tpSelector
 
bool useGsf
 

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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Member Functions inherited from MultiTrackValidatorBase
 MultiTrackValidatorBase (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidatorBase ()
 Destructor. More...
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Date:
2012/12/03 11:19:34
Revision:
1.52
Author
cerati

Definition at line 17 of file MultiTrackValidator.h.

Constructor & Destructor Documentation

MultiTrackValidator::MultiTrackValidator ( const edm::ParameterSet pset)

Constructor.

Definition at line 42 of file MultiTrackValidator.cc.

References _simHitTpMapTag, associatormap, MultiTrackValidatorBase::associators, cosmictpSelector, MultiTrackValidatorBase::dbe_, dirName_, reco::get(), edm::ParameterSet::getParameter(), histoProducerAlgo_, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, runStandalone, AlCaHLTBitMon_QueryRunRegistry::string, tpSelector, UseAssociators, and useGsf.

43  //theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet);
44 
45  ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
46  string histoProducerAlgoName = psetForHistoProducerAlgo.getParameter<string>("ComponentName");
47  histoProducerAlgo_ = MTVHistoProducerAlgoFactory::get()->create(histoProducerAlgoName ,psetForHistoProducerAlgo);
48  histoProducerAlgo_->setDQMStore(dbe_);
49 
50  dirName_ = pset.getParameter<std::string>("dirName");
51  associatormap = pset.getParameter< edm::InputTag >("associatormap");
52  UseAssociators = pset.getParameter< bool >("UseAssociators");
53 
54  m_dEdx1Tag = pset.getParameter< edm::InputTag >("dEdx1Tag");
55  m_dEdx2Tag = pset.getParameter< edm::InputTag >("dEdx2Tag");
56 
57  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
58  pset.getParameter<double>("minRapidityTP"),
59  pset.getParameter<double>("maxRapidityTP"),
60  pset.getParameter<double>("tipTP"),
61  pset.getParameter<double>("lipTP"),
62  pset.getParameter<int>("minHitTP"),
63  pset.getParameter<bool>("signalOnlyTP"),
64  pset.getParameter<bool>("chargedOnlyTP"),
65  pset.getParameter<bool>("stableOnlyTP"),
66  pset.getParameter<std::vector<int> >("pdgIdTP"));
67 
69  pset.getParameter<double>("minRapidityTP"),
70  pset.getParameter<double>("maxRapidityTP"),
71  pset.getParameter<double>("tipTP"),
72  pset.getParameter<double>("lipTP"),
73  pset.getParameter<int>("minHitTP"),
74  pset.getParameter<bool>("chargedOnlyTP"),
75  pset.getParameter<std::vector<int> >("pdgIdTP"));
76 
77  useGsf = pset.getParameter<bool>("useGsf");
78  runStandalone = pset.getParameter<bool>("runStandalone");
79 
80  _simHitTpMapTag = pset.getParameter<edm::InputTag>("simHitTpMapTag");
81 
82  if (!UseAssociators) {
83  associators.clear();
84  associators.push_back(associatormap.label());
85  }
86 
87 }
T getParameter(std::string const &) const
CosmicTrackingParticleSelector cosmictpSelector
edm::InputTag _simHitTpMapTag
MultiTrackValidatorBase(const edm::ParameterSet &pset)
Constructor.
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
TrackingParticleSelector tpSelector
edm::InputTag associatormap
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
MTVHistoProducerAlgo * histoProducerAlgo_
std::vector< std::string > associators
T get(const Candidate &c)
Definition: component.h:56
MultiTrackValidator::~MultiTrackValidator ( )
virtual

Destructor.

Definition at line 90 of file MultiTrackValidator.cc.

References histoProducerAlgo_.

90 {delete histoProducerAlgo_;}
MTVHistoProducerAlgo * histoProducerAlgo_

Member Function Documentation

void MultiTrackValidator::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
virtual

Method called once per event.

Implements edm::EDAnalyzer.

Reimplemented in MultiTrackValidatorGenPs.

Definition at line 147 of file MultiTrackValidator.cc.

References _simHitTpMapTag, MultiTrackValidatorBase::associator, associatormap, MultiTrackValidatorBase::associators, asciidump::at, MultiTrackValidatorBase::bsSrc, EncodedEventId::bunchCrossing(), reco::TrackBase::charge(), edm::HandleBase::clear(), funct::cos(), cosmictpSelector, alignCSCRings::e, edm::AssociationMap< Tag >::end(), EncodedEventId::event(), TrackingParticle::eventId(), MTVHistoProducerAlgo::fill_dedx_recoTrack_histos(), MTVHistoProducerAlgo::fill_generic_recoTrack_histos(), MTVHistoProducerAlgo::fill_generic_simTrack_histos(), MTVHistoProducerAlgo::fill_recoAssociated_simTrack_histos(), MTVHistoProducerAlgo::fill_ResoAndPull_recoTrack_histos(), MTVHistoProducerAlgo::fill_simAssociated_recoTrack_histos(), MTVHistoProducerAlgo::fill_trackBased_histos(), edm::AssociationMap< Tag >::find(), first, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByLabel(), histoProducerAlgo_, i, MultiTrackValidatorBase::ignoremissingtkcollection_, CosmicTrackingParticleSelector::initEvent(), edm::InputTag::instance(), j, edm::InputTag::label(), MultiTrackValidatorBase::label, MultiTrackValidatorBase::label_pileupinfo, MultiTrackValidatorBase::label_tp_effic, MultiTrackValidatorBase::label_tp_fake, MultiTrackValidatorBase::label_tv, LogTrace, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, TrackingParticle::momentum(), TrackingParticle::numberOfTrackerHits(), MultiTrackValidatorBase::parametersDefiner, edm::InputTag::process(), edm::Handle< T >::product(), reco::TrackBase::pt(), L1Trigger_dataformats::reco, funct::sin(), findQualityFiles::size, mathSSE::sqrt(), tpSelector, UseAssociators, TrackingParticle::vertex(), w(), and cms::Exception::what().

147  {
148  using namespace reco;
149 
150  edm::LogInfo("TrackValidator") << "\n====================================================" << "\n"
151  << "Analyzing new event" << "\n"
152  << "====================================================\n" << "\n";
153  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP;
154  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTP);
155 
156  edm::Handle<TrackingParticleCollection> TPCollectionHeff ;
157  event.getByLabel(label_tp_effic,TPCollectionHeff);
158  const TrackingParticleCollection tPCeff = *(TPCollectionHeff.product());
159 
160  edm::Handle<TrackingParticleCollection> TPCollectionHfake ;
161  event.getByLabel(label_tp_fake,TPCollectionHfake);
162  const TrackingParticleCollection tPCfake = *(TPCollectionHfake.product());
163 
164  if(parametersDefiner=="CosmicParametersDefinerForTP") {
166  //warning: make sure the TP collection used in the map is the same used in the MTV!
167  event.getByLabel(_simHitTpMapTag,simHitsTPAssoc);
168  parametersDefinerTP->initEvent(simHitsTPAssoc);
169  cosmictpSelector.initEvent(simHitsTPAssoc);
170  }
171 
172  //if (tPCeff.size()==0) {edm::LogInfo("TrackValidator")
173  //<< "TP Collection for efficiency studies has size = 0! Skipping Event." ; return;}
174  //if (tPCfake.size()==0) {edm::LogInfo("TrackValidator")
175  //<< "TP Collection for fake rate studies has size = 0! Skipping Event." ; return;}
176 
177  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
178  event.getByLabel(bsSrc,recoBeamSpotHandle);
179  reco::BeamSpot bs = *recoBeamSpotHandle;
180 
182  event.getByLabel(label_pileupinfo,puinfoH);
183  PileupSummaryInfo puinfo;
184 
185  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
186  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
187  puinfo=(*puinfoH)[puinfo_ite];
188  break;
189  }
190  }
191 
193  event.getByLabel(label_tv,tvH);
194  TrackingVertexCollection tv = *tvH;
195 
196  int w=0; //counter counting the number of sets of histograms
197  for (unsigned int ww=0;ww<associators.size();ww++){
198  for (unsigned int www=0;www<label.size();www++){
199  //
200  //get collections from the event
201  //
202  edm::Handle<View<Track> > trackCollection;
203  if(!event.getByLabel(label[www], trackCollection)&&ignoremissingtkcollection_)continue;
204  //if (trackCollection->size()==0)
205  //edm::LogInfo("TrackValidator") << "TrackCollection size = 0!" ;
206  //continue;
207  //}
208  reco::RecoToSimCollection recSimColl;
209  reco::SimToRecoCollection simRecColl;
210  //associate tracks
211  if(UseAssociators){
212  edm::LogVerbatim("TrackValidator") << "Analyzing "
213  << label[www].process()<<":"
214  << label[www].label()<<":"
215  << label[www].instance()<<" with "
216  << associators[ww].c_str() <<"\n";
217 
218  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
219  recSimColl=associator[ww]->associateRecoToSim(trackCollection,
220  TPCollectionHfake,
221  &event,&setup);
222  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
223  simRecColl=associator[ww]->associateSimToReco(trackCollection,
224  TPCollectionHeff,
225  &event,&setup);
226  }
227  else{
228  edm::LogVerbatim("TrackValidator") << "Analyzing "
229  << label[www].process()<<":"
230  << label[www].label()<<":"
231  << label[www].instance()<<" with "
232  << associatormap.process()<<":"
233  << associatormap.label()<<":"
234  << associatormap.instance()<<"\n";
235 
236  Handle<reco::SimToRecoCollection > simtorecoCollectionH;
237  event.getByLabel(associatormap,simtorecoCollectionH);
238  simRecColl= *(simtorecoCollectionH.product());
239 
240  Handle<reco::RecoToSimCollection > recotosimCollectionH;
241  event.getByLabel(associatormap,recotosimCollectionH);
242  recSimColl= *(recotosimCollectionH.product());
243  }
244 
245 
246 
247  // ########################################################
248  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
249  // ########################################################
250 
251  //compute number of tracks per eta interval
252  //
253  edm::LogVerbatim("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
254  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
255  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
256  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
257  unsigned asts(0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
258  for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){ //loop over TPs collection for tracking efficiency
259  TrackingParticleRef tpr(TPCollectionHeff, i);
260  TrackingParticle* tp=const_cast<TrackingParticle*>(tpr.get());
261  TrackingParticle::Vector momentumTP;
262  TrackingParticle::Point vertexTP;
263  double dxySim(0);
264  double dzSim(0);
265 
266  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
267  //If the TrackingParticle is collison like, get the momentum and vertex at production state
268  if(parametersDefiner=="LhcParametersDefinerForTP")
269  {
270  if(! tpSelector(*tp)) continue;
271  momentumTP = tp->momentum();
272  vertexTP = tp->vertex();
273  //Calcualte the impact parameters w.r.t. PCA
274  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tpr);
275  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tpr);
276  dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
277  dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2())
278  * momentum.z()/sqrt(momentum.perp2());
279  }
280  //If the TrackingParticle is comics, get the momentum and vertex at PCA
281  if(parametersDefiner=="CosmicParametersDefinerForTP")
282  {
283  if(! cosmictpSelector(tpr,&bs,event,setup)) continue;
284  momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
285  vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
286  dxySim = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
287  dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2())
288  * momentumTP.z()/sqrt(momentumTP.perp2());
289  }
290  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
291 
292  st++; //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
293 
294  // in the coming lines, histos are filled using as input
295  // - momentumTP
296  // - vertexTP
297  // - dxySim
298  // - dzSim
299 
301 
302 
303  // ##############################################
304  // fill RecoAssociated SimTracks' histograms
305  // ##############################################
306  // bool isRecoMatched(false); // UNUSED
307  const reco::Track* matchedTrackPointer=0;
308  std::vector<std::pair<RefToBase<Track>, double> > rt;
309  if(simRecColl.find(tpr) != simRecColl.end()){
310  rt = (std::vector<std::pair<RefToBase<Track>, double> >) simRecColl[tpr];
311  if (rt.size()!=0) {
312  ats++; //This counter counts the number of simTracks that have a recoTrack associated
313  // isRecoMatched = true; // UNUSED
314  matchedTrackPointer = rt.begin()->first.get();
315  edm::LogVerbatim("TrackValidator") << "TrackingParticle #" << st
316  << " with pt=" << sqrt(momentumTP.perp2())
317  << " associated with quality:" << rt.begin()->second <<"\n";
318  }
319  }else{
320  edm::LogVerbatim("TrackValidator")
321  << "TrackingParticle #" << st
322  << " with pt,eta,phi: "
323  << sqrt(momentumTP.perp2()) << " , "
324  << momentumTP.eta() << " , "
325  << momentumTP.phi() << " , "
326  << " NOT associated to any reco::Track" << "\n";
327  }
328 
329 
330 
331 
332  int nSimHits = tp->numberOfTrackerHits();
333 
334  double vtx_z_PU = vertexTP.z();
335  for (size_t j = 0; j < tv.size(); j++) {
336  if (tp->eventId().event() == tv[j].eventId().event()) {
337  vtx_z_PU = tv[j].position().z();
338  break;
339  }
340  }
341 
342  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,momentumTP,vertexTP,dxySim,dzSim,nSimHits,matchedTrackPointer,puinfo.getPU_NumInteractions(), vtx_z_PU);
343  sts++;
344  if (matchedTrackPointer) asts++;
345 
346 
347 
348 
349  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
350 
351  //if (st!=0) h_tracksSIM[w]->Fill(st); // TO BE FIXED
352 
353 
354  // ##############################################
355  // fill recoTracks histograms (LOOP OVER TRACKS)
356  // ##############################################
357  edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with "
358  << label[www].process()<<":"
359  << label[www].label()<<":"
360  << label[www].instance()
361  << ": " << trackCollection->size() << "\n";
362 
363  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
364  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
365  int rT(0); //This counter counts the number of recoTracks in general
366 
367 
368  // dE/dx
369  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
370  // I'm writing the interface such to take vectors of ValueMaps
373  std::vector<edm::ValueMap<reco::DeDxData> > v_dEdx;
374  v_dEdx.clear();
375  //std::cout << "PIPPO: label is " << label[www] << std::endl;
376  if (label[www].label()=="generalTracks") {
377  try {
378  event.getByLabel(m_dEdx1Tag, dEdx1Handle);
379  const edm::ValueMap<reco::DeDxData> dEdx1 = *dEdx1Handle.product();
380  event.getByLabel(m_dEdx2Tag, dEdx2Handle);
381  const edm::ValueMap<reco::DeDxData> dEdx2 = *dEdx2Handle.product();
382  v_dEdx.push_back(dEdx1);
383  v_dEdx.push_back(dEdx2);
384  } catch (cms::Exception e){
385  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
386  }
387  }
388  //end dE/dx
389 
390  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
391 
392  RefToBase<Track> track(trackCollection, i);
393  rT++;
394 
395  bool isSigSimMatched(false);
396  bool isSimMatched(false);
397  bool isChargeMatched(true);
398  int numAssocRecoTracks = 0;
399  int tpbx = 0;
400  int nSimHits = 0;
401  double sharedFraction = 0.;
402  std::vector<std::pair<TrackingParticleRef, double> > tp;
403  if(recSimColl.find(track) != recSimColl.end()){
404  tp = recSimColl[track];
405  if (tp.size()!=0) {
406  nSimHits = tp[0].first->numberOfTrackerHits();
407  sharedFraction = tp[0].second;
408  isSimMatched = true;
409  if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
410  if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocRecoTracks = simRecColl[tp[0].first].size();
411  //std::cout << numAssocRecoTracks << std::endl;
412  tpbx = tp[0].first->eventId().bunchCrossing();
413  at++;
414  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
415  TrackingParticle trackpart = *(tp[tp_ite].first);
416  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
417  isSigSimMatched = true;
418  sat++;
419  break;
420  }
421  }
422  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
423  << " associated with quality:" << tp.begin()->second <<"\n";
424  }
425  } else {
426  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
427  << " NOT associated to any TrackingParticle" << "\n";
428  }
429 
430 
431  histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction);
432 
433  // dE/dx
434  // reco::TrackRef track2 = reco::TrackRef( trackCollection, i );
435  if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(w,track, v_dEdx);
436  //if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(track2, v_dEdx);
437 
438 
439  //Fill other histos
440  //try{ //Is this really necessary ????
441 
442  if (tp.size()==0) continue;
443 
445 
446  TrackingParticleRef tpr = tp.begin()->first;
447 
448  /* TO BE FIXED LATER
449  if (associators[ww]=="TrackAssociatorByChi2"){
450  //association chi2
451  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
452  h_assochi2[www]->Fill(assocChi2);
453  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
454  }
455  else if (associators[ww]=="quickTrackAssociatorByHits"){
456  double fraction = tp.begin()->second;
457  h_assocFraction[www]->Fill(fraction);
458  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
459  }
460  */
461 
462 
463  //Get tracking particle parameters at point of closest approach to the beamline
464  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
465  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
466  int chargeTP = tpr->charge();
467 
468  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,chargeTP,
469  *track,bs.position());
470 
471 
472  //TO BE FIXED
473  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
474  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
475 
476  /*
477  } // End of try{
478  catch (cms::Exception e){
479  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
480  }
481  */
482 
483  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
484 
486 
487  edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
488  << "Total Associated (simToReco): " << ats << "\n"
489  << "Total Reconstructed: " << rT << "\n"
490  << "Total Associated (recoToSim): " << at << "\n"
491  << "Total Fakes: " << rT-at << "\n";
492 
493  w++;
494  } // End of for (unsigned int www=0;www<label.size();www++){
495  } //END of for (unsigned int ww=0;ww<associators.size();ww++){
496 
497 }
virtual char const * what() const
Definition: Exception.cc:141
int i
Definition: DBlmapReader.cc:9
int event() const
get the contents of the subdetector field (should be protected?)
CosmicTrackingParticleSelector cosmictpSelector
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
last iterator over the map (read only)
edm::InputTag _simHitTpMapTag
virtual void fill_dedx_recoTrack_histos(int count, edm::RefToBase< reco::Track > &trackref, const std::vector< edm::ValueMap< reco::DeDxData > > &v_dEdx)=0
Point vertex() const
Parent vertex position.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< const TrackAssociatorBase * > associator
virtual void fill_ResoAndPull_recoTrack_histos(int count, const TrackingParticle::Vector &momentumTP, const TrackingParticle::Point &vertexTP, int chargeTP, const reco::Track &track, const math::XYZPoint &bsPosition)=0
uint16_t size_type
math::XYZPointD Point
point in the space
virtual void fill_recoAssociated_simTrack_histos(int count, const TrackingParticle &tp, const TrackingParticle::Vector &momentumTP, const TrackingParticle::Point &vertexTP, double dxy, double dz, int nSimHits, const reco::Track *track, int numVertices, double vertz)=0
std::vector< edm::InputTag > label
T sqrt(T t)
Definition: SSEVec.h:48
virtual void fill_generic_recoTrack_histos(int count, const reco::Track &track, const math::XYZPoint &bsPosition, bool isMatched, bool isSigMatched, bool isChargeMatched, int numAssocRecoTracks, int numVertices, int tpbunchcrossing, int nSimHits, double sharedFraction)=0
int bunchCrossing() const
get the detector field from this detid
TrackingParticleSelector tpSelector
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::InputTag associatormap
unsigned int size_type
Definition: View.h:85
int j
Definition: DBlmapReader.cc:9
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
bool first
Definition: L1TdeRCT.cc:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#define LogTrace(id)
MTVHistoProducerAlgo * histoProducerAlgo_
virtual void fill_simAssociated_recoTrack_histos(int count, const reco::Track &track)=0
std::vector< TrackingVertex > TrackingVertexCollection
const T & get() const
Definition: EventSetup.h:55
virtual void fill_trackBased_histos(int count, int assTracks, int numRecoTracks, int numSimTracks)=0
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:42
EncodedEventId eventId() const
Signal source, crossing number.
std::string const & process() const
Definition: InputTag.h:46
Vector momentum() const
spatial momentum vector
Monte Carlo truth information used for tracking validation.
T w() const
std::vector< std::string > associators
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
math::XYZVectorD Vector
point in the space
virtual void fill_generic_simTrack_histos(int counter, const TrackingParticle::Vector &, const TrackingParticle::Point &vertex, int bx)=0
std::string const & instance() const
Definition: InputTag.h:43
tuple size
Write out results.
list at
Definition: asciidump.py:428
void MultiTrackValidator::beginRun ( edm::Run const &  ,
edm::EventSetup const &  setup 
)
virtual

Method called before the event loop.

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file MultiTrackValidator.cc.

References MultiTrackValidatorBase::associator, MultiTrackValidatorBase::associators, MTVHistoProducerAlgo::bookRecoHistos(), MTVHistoProducerAlgo::bookRecoHistosForStandaloneRunning(), MTVHistoProducerAlgo::bookSimHistos(), DQMStore::cd(), MultiTrackValidatorBase::dbe_, TrackerOfflineValidation_Dqm_cff::dirName, dirName_, edm::EventSetup::get(), DQMStore::goUp(), histoProducerAlgo_, MTVHistoProducerAlgo::initialize(), edm::InputTag::instance(), edm::InputTag::label(), MultiTrackValidatorBase::label, edm::InputTag::process(), edm::ESHandle< class >::product(), linker::replace(), runStandalone, DQMStore::setCurrentFolder(), UseAssociators, and w().

92  {
93  // dbe_->showDirStructure();
94 
95  //int j=0; //is This Necessary ???
96  for (unsigned int ww=0;ww<associators.size();ww++){
97  for (unsigned int www=0;www<label.size();www++){
98  dbe_->cd();
99  InputTag algo = label[www];
100  string dirName=dirName_;
101  if (algo.process()!="")
102  dirName+=algo.process()+"_";
103  if(algo.label()!="")
104  dirName+=algo.label()+"_";
105  if(algo.instance()!="")
106  dirName+=algo.instance()+"_";
107  if (dirName.find("Tracks")<dirName.length()){
108  dirName.replace(dirName.find("Tracks"),6,"");
109  }
110  string assoc= associators[ww];
111  if (assoc.find("Track")<assoc.length()){
112  assoc.replace(assoc.find("Track"),5,"");
113  }
114  dirName+=assoc;
115  std::replace(dirName.begin(), dirName.end(), ':', '_');
116 
117  dbe_->setCurrentFolder(dirName.c_str());
118 
119  // vector of vector initialization
120  histoProducerAlgo_->initialize(); //TO BE FIXED. I'D LIKE TO AVOID THIS CALL
121 
122  dbe_->goUp(); //Is this really necessary ???
123  string subDirName = dirName + "/simulation";
124  dbe_->setCurrentFolder(subDirName.c_str());
125 
126  //Booking histograms concerning with simulated tracks
128 
129  dbe_->cd();
130  dbe_->setCurrentFolder(dirName.c_str());
131 
132  //Booking histograms concerning with reconstructed tracks
135 
136  if (UseAssociators) {
138  for (unsigned int w=0;w<associators.size();w++) {
139  setup.get<TrackAssociatorRecord>().get(associators[w],theAssociator);
140  associator.push_back( theAssociator.product() );
141  }//end loop w
142  }
143  }//end loop www
144  }// end loop ww
145 }
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:411
std::vector< const TrackAssociatorBase * > associator
virtual void bookSimHistos()=0
def replace
Definition: linker.py:10
virtual void bookRecoHistos()=0
std::vector< edm::InputTag > label
virtual void initialize()=0
MTVHistoProducerAlgo * histoProducerAlgo_
T const * product() const
Definition: ESHandle.h:62
std::string const & label() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:46
virtual void bookRecoHistosForStandaloneRunning()=0
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:445
T w() const
std::vector< std::string > associators
std::string const & instance() const
Definition: InputTag.h:43
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void MultiTrackValidator::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
virtual

Method called at the end of the event loop.

Reimplemented from edm::EDAnalyzer.

Definition at line 499 of file MultiTrackValidator.cc.

References MultiTrackValidatorBase::associators, MultiTrackValidatorBase::dbe_, MTVHistoProducerAlgo::fillHistosFromVectors(), MTVHistoProducerAlgo::fillProfileHistosFromVectors(), MTVHistoProducerAlgo::finalHistoFits(), histoProducerAlgo_, MultiTrackValidatorBase::label, MultiTrackValidatorBase::out, runStandalone, DQMStore::save(), MultiTrackValidatorBase::skipHistoFit, and w().

499  {
500  int w=0;
501  for (unsigned int ww=0;ww<associators.size();ww++){
502  for (unsigned int www=0;www<label.size();www++){
506  w++;
507  }
508  }
509  if ( out.size() != 0 && dbe_ ) dbe_->save(out);
510 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
std::vector< edm::InputTag > label
virtual void fillProfileHistosFromVectors(int counter)=0
virtual void finalHistoFits(int counter)=0
MTVHistoProducerAlgo * histoProducerAlgo_
virtual void fillHistosFromVectors(int counter)=0
T w() const
std::vector< std::string > associators

Member Data Documentation

edm::InputTag MultiTrackValidator::_simHitTpMapTag
private

Definition at line 49 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

edm::InputTag MultiTrackValidator::associatormap
protected
CosmicTrackingParticleSelector MultiTrackValidator::cosmictpSelector
private

Definition at line 48 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

std::string MultiTrackValidator::dirName_
private

Definition at line 41 of file MultiTrackValidator.h.

Referenced by beginRun(), and MultiTrackValidator().

MTVHistoProducerAlgo* MultiTrackValidator::histoProducerAlgo_
protected
bool MultiTrackValidator::runStandalone
private

Definition at line 44 of file MultiTrackValidator.h.

Referenced by beginRun(), endRun(), and MultiTrackValidator().

TrackingParticleSelector MultiTrackValidator::tpSelector
private

Definition at line 47 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

bool MultiTrackValidator::UseAssociators
protected
bool MultiTrackValidator::useGsf
private

Definition at line 43 of file MultiTrackValidator.h.

Referenced by MultiTrackValidator().