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:
DQMEDAnalyzer MultiTrackValidatorBase edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase MultiTrackValidatorGenPs

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Method called once per event. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
 Method called to book the DQM histograms. 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 DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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 assMapInput
 
edm::EDGetTokenT
< reco::RecoToSimCollection
associatormapRtS
 
edm::EDGetTokenT
< reco::SimToRecoCollection
associatormapStR
 
MTVHistoProducerAlgohistoProducerAlgo_
 
bool UseAssociators
 
- Protected Attributes inherited from MultiTrackValidatorBase
std::vector< const
TrackAssociatorBase * > 
associator
 
std::vector< std::string > associators
 
edm::EDGetTokenT< reco::BeamSpotbsSrc
 
bool ignoremissingtkcollection_
 
std::vector< edm::InputTaglabel
 
edm::EDGetTokenT< std::vector
< PileupSummaryInfo > > 
label_pileupinfo
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_effic
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_fake
 
edm::EDGetTokenT
< TrackingVertexCollection
label_tv
 
std::vector< edm::EDGetTokenT
< edm::View< reco::Track > > > 
labelToken
 
std::vector< edm::EDGetTokenT
< edm::View< TrajectorySeed > > > 
labelTokenSeed
 
edm::EDGetTokenT
< edm::ValueMap
< reco::DeDxData > > 
m_dEdx1Tag
 
edm::EDGetTokenT
< edm::ValueMap
< reco::DeDxData > > 
m_dEdx2Tag
 
std::string out
 
std::string parametersDefiner
 
std::string sim
 
bool skipHistoFit
 
edm::ESHandle< MagneticFieldtheMF
 

Private Attributes

edm::EDGetTokenT
< SimHitTPAssociationProducer::SimHitTPAssociationList
_simHitTpMapTag
 
CosmicTrackingParticleSelector cosmictpSelector
 
std::string dirName_
 
TrackingParticleSelector dRtpSelector
 
edm::EDGetTokenT< edm::View
< reco::Track > > 
labelTokenForDrCalculation
 
bool runStandalone
 
TrackingParticleSelector tpSelector
 
bool useGsf
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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, edm::ConsumesCollector &&iC, bool isSeed=false)
 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 45 of file MultiTrackValidator.cc.

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

46  //theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector());
47 
48  ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
49  string histoProducerAlgoName = psetForHistoProducerAlgo.getParameter<string>("ComponentName");
50  histoProducerAlgo_ = MTVHistoProducerAlgoFactory::get()->create(histoProducerAlgoName ,psetForHistoProducerAlgo, consumesCollector());
51 
52  dirName_ = pset.getParameter<std::string>("dirName");
53  assMapInput = pset.getParameter< edm::InputTag >("associatormap");
54  associatormapStR = mayConsume<reco::SimToRecoCollection>(assMapInput);
55  associatormapRtS = mayConsume<reco::RecoToSimCollection>(assMapInput);
56  UseAssociators = pset.getParameter< bool >("UseAssociators");
57 
58  m_dEdx1Tag = mayConsume<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx1Tag"));
59  m_dEdx2Tag = mayConsume<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx2Tag"));
60 
61  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
62  pset.getParameter<double>("minRapidityTP"),
63  pset.getParameter<double>("maxRapidityTP"),
64  pset.getParameter<double>("tipTP"),
65  pset.getParameter<double>("lipTP"),
66  pset.getParameter<int>("minHitTP"),
67  pset.getParameter<bool>("signalOnlyTP"),
68  pset.getParameter<bool>("chargedOnlyTP"),
69  pset.getParameter<bool>("stableOnlyTP"),
70  pset.getParameter<std::vector<int> >("pdgIdTP"));
71 
73  pset.getParameter<double>("minRapidityTP"),
74  pset.getParameter<double>("maxRapidityTP"),
75  pset.getParameter<double>("tipTP"),
76  pset.getParameter<double>("lipTP"),
77  pset.getParameter<int>("minHitTP"),
78  pset.getParameter<bool>("chargedOnlyTP"),
79  pset.getParameter<std::vector<int> >("pdgIdTP"));
80 
81 
82  ParameterSet psetVsEta = psetForHistoProducerAlgo.getParameter<ParameterSet>("TpSelectorForEfficiencyVsEta");
83  dRtpSelector = TrackingParticleSelector(psetVsEta.getParameter<double>("ptMin"),
84  psetVsEta.getParameter<double>("minRapidity"),
85  psetVsEta.getParameter<double>("maxRapidity"),
86  psetVsEta.getParameter<double>("tip"),
87  psetVsEta.getParameter<double>("lip"),
88  psetVsEta.getParameter<int>("minHit"),
89  psetVsEta.getParameter<bool>("signalOnly"),
90  psetVsEta.getParameter<bool>("chargedOnly"),
91  psetVsEta.getParameter<bool>("stableOnly"),
92  psetVsEta.getParameter<std::vector<int> >("pdgId"));
93 
94  useGsf = pset.getParameter<bool>("useGsf");
95  runStandalone = pset.getParameter<bool>("runStandalone");
96 
97  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
98 
99  labelTokenForDrCalculation = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("trackCollectionForDrCalculation"));
100 
101  if (!UseAssociators) {
102  associators.clear();
103  associators.push_back(assMapInput.label());
104  }
105 
106 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
CosmicTrackingParticleSelector cosmictpSelector
edm::EDGetTokenT< reco::RecoToSimCollection > associatormapRtS
TrackingParticleSelector dRtpSelector
edm::EDGetTokenT< reco::SimToRecoCollection > associatormapStR
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackingParticleSelector tpSelector
MultiTrackValidatorBase(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC, bool isSeed=false)
Constructor.
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
MTVHistoProducerAlgo * histoProducerAlgo_
std::string const & label() const
Definition: InputTag.h:42
std::vector< std::string > associators
T get(const Candidate &c)
Definition: component.h:55
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
MultiTrackValidator::~MultiTrackValidator ( )
virtual

Destructor.

Definition at line 109 of file MultiTrackValidator.cc.

References histoProducerAlgo_.

109 {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::stream::EDAnalyzerBase.

Reimplemented in MultiTrackValidatorGenPs.

Definition at line 165 of file MultiTrackValidator.cc.

References _simHitTpMapTag, assMapInput, MultiTrackValidatorBase::associator, associatormapRtS, associatormapStR, MultiTrackValidatorBase::associators, asciidump::at, MultiTrackValidatorBase::bsSrc, EncodedEventId::bunchCrossing(), reco::TrackBase::charge(), edm::HandleBase::clear(), funct::cos(), cosmictpSelector, reco::deltaR2(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, dRtpSelector, alignCSCRings::e, edm::AssociationMap< Tag >::end(), eta(), 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::getByToken(), 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::labelToken, labelTokenForDrCalculation, LogTrace, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, max(), bookConverter::min, TrackingParticle::momentum(), TrackingParticle::numberOfTrackerHits(), AlCaHLTBitMon_ParallelJobs::p, MultiTrackValidatorBase::parametersDefiner, phi, 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().

165  {
166  using namespace reco;
167 
168  edm::LogInfo("TrackValidator") << "\n====================================================" << "\n"
169  << "Analyzing new event" << "\n"
170  << "====================================================\n" << "\n";
171  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTPHandle;
172  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTPHandle);
173  //Since we modify the object, we must clone it
174  auto parametersDefinerTP = parametersDefinerTPHandle->clone();
175 
176  edm::Handle<TrackingParticleCollection> TPCollectionHeff ;
177  event.getByToken(label_tp_effic,TPCollectionHeff);
178  TrackingParticleCollection const & tPCeff = *(TPCollectionHeff.product());
179 
180  edm::Handle<TrackingParticleCollection> TPCollectionHfake ;
181  event.getByToken(label_tp_fake,TPCollectionHfake);
182 
183 
184  if(parametersDefiner=="CosmicParametersDefinerForTP") {
186  //warning: make sure the TP collection used in the map is the same used in the MTV!
187  event.getByToken(_simHitTpMapTag,simHitsTPAssoc);
188  parametersDefinerTP->initEvent(simHitsTPAssoc);
189  cosmictpSelector.initEvent(simHitsTPAssoc);
190  }
191 
192 
193  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
194  event.getByToken(bsSrc,recoBeamSpotHandle);
195  reco::BeamSpot const & bs = *recoBeamSpotHandle;
196 
198  event.getByToken(label_pileupinfo,puinfoH);
199  PileupSummaryInfo puinfo;
200 
201  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
202  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
203  puinfo=(*puinfoH)[puinfo_ite];
204  break;
205  }
206  }
207 
208  /*
209  edm::Handle<TrackingVertexCollection> tvH;
210  event.getByToken(label_tv,tvH);
211  TrackingVertexCollection const & tv = *tvH;
212  */
213 
214  //calculate dR for TPs
215  float dR_tPCeff[(*TPCollectionHeff).size()];
216  {
217  int j=0;
218  float etaL[(*TPCollectionHeff).size()], phiL[(*TPCollectionHeff).size()];
219  bool okL[(*TPCollectionHeff).size()];
220  for ( auto const & tp2 : *TPCollectionHeff) {
221  okL[j]=false;
222  if(tpSelector(tp2)) { //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
223  okL[j]=true;
224  auto && p = tp2.momentum();
225  etaL[j] = etaFromXYZ(p.x(),p.y(),p.z());
226  phiL[j] = atan2f(p.y(),p.x());
227 
228  }
229  ++j;
230  }
231  auto i=0U;
232  for ( auto const & tp : *TPCollectionHeff) {
234  if(dRtpSelector(tp)) {//only for those needed for efficiency!
235  auto && p = tp.momentum();
236  float eta = etaFromXYZ(p.x(),p.y(),p.z());
237  float phi = atan2f(p.y(),p.x());
238  for (auto j=0U; j< (*TPCollectionHeff).size(); ++j ) {
239  if (i==j) {continue;}
240  if(okL[j]) { //calculare dR wrt inclusive collection (also with PU, low pT, displaced)
241  auto dR_tmp = reco::deltaR2(eta, phi, etaL[j], phiL[j]);
242  if (dR_tmp<dR) dR=dR_tmp;
243  }
244  } // ttp2 (j)
245  }
246  dR_tPCeff[i++] = std::sqrt(dR);
247  } // tp
248  }
249 
250  edm::Handle<View<Track> > trackCollectionForDrCalculation;
251  event.getByToken(labelTokenForDrCalculation, trackCollectionForDrCalculation);
252 
253  int w=0; //counter counting the number of sets of histograms
254  for (unsigned int ww=0;ww<associators.size();ww++){
255  for (unsigned int www=0;www<label.size();www++){
256  //
257  //get collections from the event
258  //
259  edm::Handle<View<Track> > trackCollection;
260  if(!event.getByToken(labelToken[www], trackCollection)&&ignoremissingtkcollection_)continue;
261 
262  reco::RecoToSimCollection const * recSimCollP=nullptr;
263  reco::SimToRecoCollection const * simRecCollP=nullptr;
264  reco::RecoToSimCollection recSimCollL;
265  reco::SimToRecoCollection simRecCollL;
266 
267  //associate tracks
268  if(UseAssociators){
269  edm::LogVerbatim("TrackValidator") << "Analyzing "
270  << label[www].process()<<":"
271  << label[www].label()<<":"
272  << label[www].instance()<<" with "
273  << associators[ww].c_str() <<"\n";
274 
275  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
276  recSimCollL = std::move(associator[ww]->associateRecoToSim(trackCollection,
277  TPCollectionHfake,
278  &event,&setup));
279  recSimCollP = &recSimCollL;
280  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
281  simRecCollL = std::move(associator[ww]->associateSimToReco(trackCollection,
282  TPCollectionHeff,
283  &event,&setup));
284  simRecCollP = &simRecCollL;
285  }
286  else{
287  edm::LogVerbatim("TrackValidator") << "Analyzing "
288  << label[www].process()<<":"
289  << label[www].label()<<":"
290  << label[www].instance()<<" with "
291  << assMapInput.process()<<":"
292  << assMapInput.label()<<":"
293  << assMapInput.instance()<<"\n";
294 
295  Handle<reco::SimToRecoCollection > simtorecoCollectionH;
296  event.getByToken(associatormapStR,simtorecoCollectionH);
297  simRecCollP = simtorecoCollectionH.product();
298 
299  Handle<reco::RecoToSimCollection > recotosimCollectionH;
300  event.getByToken(associatormapRtS,recotosimCollectionH);
301  recSimCollP = recotosimCollectionH.product();
302  }
303 
304  reco::RecoToSimCollection const & recSimColl = *recSimCollP;
305  reco::SimToRecoCollection const & simRecColl = *simRecCollP;
306 
307 
308 
309  // ########################################################
310  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
311  // ########################################################
312 
313  //compute number of tracks per eta interval
314  //
315  edm::LogVerbatim("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
316  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
317  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
318  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
319  unsigned asts(0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
320  for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){ //loop over TPs collection for tracking efficiency
321  TrackingParticleRef tpr(TPCollectionHeff, i);
322  TrackingParticle* tp=const_cast<TrackingParticle*>(tpr.get()); // why????
323  TrackingParticle::Vector momentumTP;
324  TrackingParticle::Point vertexTP;
325  double dxySim(0);
326  double dzSim(0);
327  double dR=dR_tPCeff[i];
328 
329  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
330  //If the TrackingParticle is collison like, get the momentum and vertex at production state
331  if(parametersDefiner=="LhcParametersDefinerForTP" || parametersDefiner=="hltLhcParametersDefinerForTP")
332  {
333  if(! tpSelector(*tp)) continue;
334  momentumTP = tp->momentum();
335  vertexTP = tp->vertex();
336  //Calcualte the impact parameters w.r.t. PCA
337  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tpr);
338  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tpr);
339  dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
340  dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2())
341  * momentum.z()/sqrt(momentum.perp2());
342  }
343  //If the TrackingParticle is comics, get the momentum and vertex at PCA
344  if(parametersDefiner=="CosmicParametersDefinerForTP")
345  {
346  if(! cosmictpSelector(tpr,&bs,event,setup)) continue;
347  momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
348  vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
349  dxySim = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
350  dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2())
351  * momentumTP.z()/sqrt(momentumTP.perp2());
352  }
353  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
354 
355  st++; //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
356 
357  // in the coming lines, histos are filled using as input
358  // - momentumTP
359  // - vertexTP
360  // - dxySim
361  // - dzSim
362 
364 
365 
366  // ##############################################
367  // fill RecoAssociated SimTracks' histograms
368  // ##############################################
369  const reco::Track* matchedTrackPointer=0;
370  if(simRecColl.find(tpr) != simRecColl.end()){
371  auto const & rt = simRecColl[tpr];
372  if (rt.size()!=0) {
373  ats++; //This counter counts the number of simTracks that have a recoTrack associated
374  // isRecoMatched = true; // UNUSED
375  matchedTrackPointer = rt.begin()->first.get();
376  edm::LogVerbatim("TrackValidator") << "TrackingParticle #" << st
377  << " with pt=" << sqrt(momentumTP.perp2())
378  << " associated with quality:" << rt.begin()->second <<"\n";
379  }
380  }else{
381  edm::LogVerbatim("TrackValidator")
382  << "TrackingParticle #" << st
383  << " with pt,eta,phi: "
384  << sqrt(momentumTP.perp2()) << " , "
385  << momentumTP.eta() << " , "
386  << momentumTP.phi() << " , "
387  << " NOT associated to any reco::Track" << "\n";
388  }
389 
390 
391 
392 
393  int nSimHits = tp->numberOfTrackerHits();
394  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,momentumTP,vertexTP,dxySim,dzSim,nSimHits,matchedTrackPointer,puinfo.getPU_NumInteractions(), dR);
395  sts++;
396  if (matchedTrackPointer) asts++;
397 
398 
399 
400 
401  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
402 
403  //if (st!=0) h_tracksSIM[w]->Fill(st); // TO BE FIXED
404 
405 
406  // ##############################################
407  // fill recoTracks histograms (LOOP OVER TRACKS)
408  // ##############################################
409  edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with "
410  << label[www].process()<<":"
411  << label[www].label()<<":"
412  << label[www].instance()
413  << ": " << trackCollection->size() << "\n";
414 
415  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
416  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
417  int rT(0); //This counter counts the number of recoTracks in general
418 
419 
420  // dE/dx
421  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
422  // I'm writing the interface such to take vectors of ValueMaps
425  std::vector<edm::ValueMap<reco::DeDxData> > v_dEdx;
426  v_dEdx.clear();
427  if (label[www].label()=="generalTracks") {
428  try {
429  event.getByToken(m_dEdx1Tag, dEdx1Handle);
430  const edm::ValueMap<reco::DeDxData> dEdx1 = *dEdx1Handle.product();
431  event.getByToken(m_dEdx2Tag, dEdx2Handle);
432  const edm::ValueMap<reco::DeDxData> dEdx2 = *dEdx2Handle.product();
433  v_dEdx.push_back(dEdx1);
434  v_dEdx.push_back(dEdx2);
435  } catch (cms::Exception e){
436  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
437  }
438  }
439  //end dE/dx
440 
441 
442  //calculate dR for tracks
443  float dR_trk[trackCollection->size()];
444  int i=0;
445  float etaL[trackCollectionForDrCalculation->size()];
446  float phiL[trackCollectionForDrCalculation->size()];
447  for (auto const & track2 : *trackCollectionForDrCalculation) {
448  auto && p = track2.momentum();
449  etaL[i] = etaFromXYZ(p.x(),p.y(),p.z());
450  phiL[i] = atan2f(p.y(),p.x());
451  ++i;
452  }
453  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
454  auto const & track = (*trackCollection)[i];
456  auto && p = track.momentum();
457  float eta = etaFromXYZ(p.x(),p.y(),p.z());
458  float phi = atan2f(p.y(),p.x());
459  for(View<Track>::size_type j=0; j<trackCollectionForDrCalculation->size(); ++j){
460  auto dR_tmp = reco::deltaR2(eta, phi, etaL[j], phiL[j]);
461  if ( (dR_tmp<dR) & (dR_tmp>std::numeric_limits<float>::min())) dR=dR_tmp;
462  }
463  dR_trk[i] = std::sqrt(dR);
464  }
465 
466  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
467 
468  RefToBase<Track> track(trackCollection, i);
469  rT++;
470 
472 
473  bool isSigSimMatched(false);
474  bool isSimMatched(false);
475  bool isChargeMatched(true);
476  int numAssocRecoTracks = 0;
477  int nSimHits = 0;
478  double sharedFraction = 0.;
479  auto const & tp = (recSimColl.find(track) != recSimColl.end()) ? recSimColl[track] : dummyTP;
480 
481  if (!tp.empty()) {
482  nSimHits = tp[0].first->numberOfTrackerHits();
483  sharedFraction = tp[0].second;
484  isSimMatched = true;
485  if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
486  if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocRecoTracks = simRecColl[tp[0].first].size();
487  at++;
488  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
489  TrackingParticle trackpart = *(tp[tp_ite].first);
490  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
491  isSigSimMatched = true;
492  sat++;
493  break;
494  }
495  }
496  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
497  << " associated with quality:" << tp.begin()->second <<"\n";
498  } else {
499  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
500  << " NOT associated to any TrackingParticle" << "\n";
501  }
502 
503  double dR=dR_trk[i];
504  histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction,dR);
505 
506  // dE/dx
507  // reco::TrackRef track2 = reco::TrackRef( trackCollection, i );
508  if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(w,track, v_dEdx);
509  //if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(track2, v_dEdx);
510 
511 
512  //Fill other histos
513  //try{ //Is this really necessary ????
514 
515  if (tp.size()==0) continue;
516 
518 
519  TrackingParticleRef tpr = tp.begin()->first;
520 
521  /* TO BE FIXED LATER
522  if (associators[ww]=="TrackAssociatorByChi2"){
523  //association chi2
524  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
525  h_assochi2[www]->Fill(assocChi2);
526  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
527  }
528  else if (associators[ww]=="quickTrackAssociatorByHits"){
529  double fraction = tp.begin()->second;
530  h_assocFraction[www]->Fill(fraction);
531  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
532  }
533  */
534 
535 
536  //Get tracking particle parameters at point of closest approach to the beamline
537  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
538  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
539  int chargeTP = tpr->charge();
540 
541  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,chargeTP,
542  *track,bs.position());
543 
544 
545  //TO BE FIXED
546  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
547  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
548 
549  /*
550  } // End of try{
551  catch (cms::Exception e){
552  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
553  }
554  */
555 
556  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
557 
559 
560  edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
561  << "Total Associated (simToReco): " << ats << "\n"
562  << "Total Reconstructed: " << rT << "\n"
563  << "Total Associated (recoToSim): " << at << "\n"
564  << "Total Fakes: " << rT-at << "\n";
565 
566  w++;
567  } // End of for (unsigned int www=0;www<label.size();www++){
568  } //END of for (unsigned int ww=0;ww<associators.size();ww++){
569 
570 }
virtual char const * what() const
Definition: Exception.cc:141
type
Definition: HCALResponse.h:21
unsigned int size_type
Definition: View.h:85
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
int event() const
get the contents of the subdetector field (should be protected?)
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
CosmicTrackingParticleSelector cosmictpSelector
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
last iterator over the map (read only)
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual void fill_dedx_recoTrack_histos(int count, edm::RefToBase< reco::Track > &trackref, const std::vector< edm::ValueMap< reco::DeDxData > > &v_dEdx)=0
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
edm::EDGetTokenT< reco::RecoToSimCollection > associatormapRtS
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
TrackingParticleSelector dRtpSelector
T eta() const
uint16_t size_type
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 dR)=0
edm::EDGetTokenT< reco::SimToRecoCollection > associatormapStR
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
std::vector< edm::InputTag > label
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
int bunchCrossing() const
get the detector field from this detid
TrackingParticleSelector tpSelector
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
bool first
Definition: L1TdeRCT.cc:75
#define LogTrace(id)
MTVHistoProducerAlgo * histoProducerAlgo_
virtual void fill_simAssociated_recoTrack_histos(int count, const reco::Track &track)=0
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
virtual void fill_trackBased_histos(int count, int assTracks, int numRecoTracks, int numSimTracks)=0
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58
std::string const & label() const
Definition: InputTag.h:42
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
std::string const & process() const
Definition: InputTag.h:46
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 nSimHits, double sharedFraction, double dR)=0
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.
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
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
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
std::string const & instance() const
Definition: InputTag.h:43
tuple size
Write out results.
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
list at
Definition: asciidump.py:428
Definition: DDAxes.h:10
void MultiTrackValidator::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  ,
edm::EventSetup const &  setup 
)
virtual

Method called to book the DQM histograms.

Implements DQMEDAnalyzer.

Definition at line 112 of file MultiTrackValidator.cc.

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

112  {
113 
114  for (unsigned int ww=0;ww<associators.size();ww++){
115  for (unsigned int www=0;www<label.size();www++){
116  ibook.cd();
117  InputTag algo = label[www];
118  string dirName=dirName_;
119  if (algo.process()!="")
120  dirName+=algo.process()+"_";
121  if(algo.label()!="")
122  dirName+=algo.label()+"_";
123  if(algo.instance()!="")
124  dirName+=algo.instance()+"_";
125  if (dirName.find("Tracks")<dirName.length()){
126  dirName.replace(dirName.find("Tracks"),6,"");
127  }
128  string assoc= associators[ww];
129  if (assoc.find("Track")<assoc.length()){
130  assoc.replace(assoc.find("Track"),5,"");
131  }
132  dirName+=assoc;
133  std::replace(dirName.begin(), dirName.end(), ':', '_');
134 
135  ibook.setCurrentFolder(dirName.c_str());
136 
137  // vector of vector initialization
138  histoProducerAlgo_->initialize(); //TO BE FIXED. I'D LIKE TO AVOID THIS CALL
139 
140  string subDirName = dirName + "/simulation";
141  ibook.setCurrentFolder(subDirName.c_str());
142 
143  //Booking histograms concerning with simulated tracks
145 
146  ibook.cd();
147  ibook.setCurrentFolder(dirName.c_str());
148 
149  //Booking histograms concerning with reconstructed tracks
152 
153  if (UseAssociators) {
155  for (unsigned int w=0;w<associators.size();w++) {
156  setup.get<TrackAssociatorRecord>().get(associators[w],theAssociator);
157  associator.push_back( theAssociator.product() );
158  }//end loop w
159  }
160  }//end loop www
161  }// end loop ww
162 }
void cd(void)
Definition: DQMStore.cc:266
std::vector< const TrackAssociatorBase * > associator
virtual void bookRecoHistosForStandaloneRunning(DQMStore::IBooker &ibook)=0
std::vector< edm::InputTag > label
virtual void bookRecoHistos(DQMStore::IBooker &ibook)=0
virtual void initialize()=0
virtual void bookSimHistos(DQMStore::IBooker &ibook)=0
MTVHistoProducerAlgo * histoProducerAlgo_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: ESHandle.h:86
std::string const & label() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:46
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 MultiTrackValidator::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
virtual

Method called at the end of the event loop.

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 572 of file MultiTrackValidator.cc.

References MultiTrackValidatorBase::associators, MTVHistoProducerAlgo::fillProfileHistosFromVectors(), MTVHistoProducerAlgo::finalHistoFits(), histoProducerAlgo_, MultiTrackValidatorBase::label, runStandalone, MultiTrackValidatorBase::skipHistoFit, and w().

572  {
573  int w=0;
574  for (unsigned int ww=0;ww<associators.size();ww++){
575  for (unsigned int www=0;www<label.size();www++){
578  w++;
579  }
580  }
581  //if ( out.size() != 0 && dbe_ ) dbe_->save(out);
582 }
std::vector< edm::InputTag > label
virtual void fillProfileHistosFromVectors(int counter)=0
virtual void finalHistoFits(int counter)=0
MTVHistoProducerAlgo * histoProducerAlgo_
T w() const
std::vector< std::string > associators

Member Data Documentation

edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> MultiTrackValidator::_simHitTpMapTag
private

Definition at line 51 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

edm::InputTag MultiTrackValidator::assMapInput
protected
edm::EDGetTokenT<reco::RecoToSimCollection> MultiTrackValidator::associatormapRtS
protected
edm::EDGetTokenT<reco::SimToRecoCollection> MultiTrackValidator::associatormapStR
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 bookHistograms(), and MultiTrackValidator().

TrackingParticleSelector MultiTrackValidator::dRtpSelector
private

Definition at line 49 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

MTVHistoProducerAlgo* MultiTrackValidator::histoProducerAlgo_
protected
edm::EDGetTokenT<edm::View<reco::Track> > MultiTrackValidator::labelTokenForDrCalculation
private

Definition at line 52 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

bool MultiTrackValidator::runStandalone
private

Definition at line 44 of file MultiTrackValidator.h.

Referenced by bookHistograms(), 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().