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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) 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
 
- 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::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

Author
cerati

Definition at line 15 of file MultiTrackValidator.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 43 of file MultiTrackValidator.cc.

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

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

Destructor.

Definition at line 91 of file MultiTrackValidator.cc.

References histoProducerAlgo_.

91 {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 148 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(), dt_dqm_sourceclient_common_cff::reco, funct::sin(), findQualityFiles::size, mathSSE::sqrt(), tpSelector, UseAssociators, TrackingParticle::vertex(), w(), and cms::Exception::what().

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

93  {
94  // dbe_->showDirStructure();
95 
96  //int j=0; //is This Necessary ???
97  for (unsigned int ww=0;ww<associators.size();ww++){
98  for (unsigned int www=0;www<label.size();www++){
99  dbe_->cd();
100  InputTag algo = label[www];
101  string dirName=dirName_;
102  if (algo.process()!="")
103  dirName+=algo.process()+"_";
104  if(algo.label()!="")
105  dirName+=algo.label()+"_";
106  if(algo.instance()!="")
107  dirName+=algo.instance()+"_";
108  if (dirName.find("Tracks")<dirName.length()){
109  dirName.replace(dirName.find("Tracks"),6,"");
110  }
111  string assoc= associators[ww];
112  if (assoc.find("Track")<assoc.length()){
113  assoc.replace(assoc.find("Track"),5,"");
114  }
115  dirName+=assoc;
116  std::replace(dirName.begin(), dirName.end(), ':', '_');
117 
118  dbe_->setCurrentFolder(dirName.c_str());
119 
120  // vector of vector initialization
121  histoProducerAlgo_->initialize(); //TO BE FIXED. I'D LIKE TO AVOID THIS CALL
122 
123  dbe_->goUp(); //Is this really necessary ???
124  string subDirName = dirName + "/simulation";
125  dbe_->setCurrentFolder(subDirName.c_str());
126 
127  //Booking histograms concerning with simulated tracks
129 
130  dbe_->cd();
131  dbe_->setCurrentFolder(dirName.c_str());
132 
133  //Booking histograms concerning with reconstructed tracks
136 
137  if (UseAssociators) {
139  for (unsigned int w=0;w<associators.size();w++) {
140  setup.get<TrackAssociatorRecord>().get(associators[w],theAssociator);
141  associator.push_back( theAssociator.product() );
142  }//end loop w
143  }
144  }//end loop www
145  }// end loop ww
146 }
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:561
std::vector< const TrackAssociatorBase * > associator
virtual void bookSimHistos()=0
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:595
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:584
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 500 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().

500  {
501  int w=0;
502  for (unsigned int ww=0;ww<associators.size();ww++){
503  for (unsigned int www=0;www<label.size();www++){
507  w++;
508  }
509  }
510  if ( out.size() != 0 && dbe_ ) dbe_->save(out);
511 }
std::vector< edm::InputTag > label
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
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 47 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

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

Definition at line 46 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

std::string MultiTrackValidator::dirName_
private

Definition at line 39 of file MultiTrackValidator.h.

Referenced by beginRun(), and MultiTrackValidator().

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

Definition at line 42 of file MultiTrackValidator.h.

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

TrackingParticleSelector MultiTrackValidator::tpSelector
private

Definition at line 45 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

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

Definition at line 41 of file MultiTrackValidator.h.

Referenced by MultiTrackValidator().