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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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< 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 43 of file MultiTrackValidator.cc.

References _simHitTpMapTag, assMapInput, associatormapRtS, associatormapStR, MultiTrackValidatorBase::associators, edm::EDConsumerBase::consumesCollector(), cosmictpSelector, dirName_, dRtpSelector, reco::get(), edm::ParameterSet::getParameter(), histoProducerAlgo_, HLT_25ns14e33_v1_cff::InputTag, labelTokenForDrCalculation, 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 
50  dirName_ = pset.getParameter<std::string>("dirName");
51  assMapInput = pset.getParameter< edm::InputTag >("associatormap");
52  associatormapStR = mayConsume<reco::SimToRecoCollection>(assMapInput);
53  associatormapRtS = mayConsume<reco::RecoToSimCollection>(assMapInput);
54  UseAssociators = pset.getParameter< bool >("UseAssociators");
55 
56  m_dEdx1Tag = mayConsume<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx1Tag"));
57  m_dEdx2Tag = mayConsume<edm::ValueMap<reco::DeDxData> >(pset.getParameter< edm::InputTag >("dEdx2Tag"));
58 
59  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
60  pset.getParameter<double>("minRapidityTP"),
61  pset.getParameter<double>("maxRapidityTP"),
62  pset.getParameter<double>("tipTP"),
63  pset.getParameter<double>("lipTP"),
64  pset.getParameter<int>("minHitTP"),
65  pset.getParameter<bool>("signalOnlyTP"),
66  pset.getParameter<bool>("chargedOnlyTP"),
67  pset.getParameter<bool>("stableOnlyTP"),
68  pset.getParameter<std::vector<int> >("pdgIdTP"));
69 
71  pset.getParameter<double>("minRapidityTP"),
72  pset.getParameter<double>("maxRapidityTP"),
73  pset.getParameter<double>("tipTP"),
74  pset.getParameter<double>("lipTP"),
75  pset.getParameter<int>("minHitTP"),
76  pset.getParameter<bool>("chargedOnlyTP"),
77  pset.getParameter<std::vector<int> >("pdgIdTP"));
78 
79 
80  ParameterSet psetVsEta = psetForHistoProducerAlgo.getParameter<ParameterSet>("TpSelectorForEfficiencyVsEta");
81  dRtpSelector = TrackingParticleSelector(psetVsEta.getParameter<double>("ptMin"),
82  psetVsEta.getParameter<double>("minRapidity"),
83  psetVsEta.getParameter<double>("maxRapidity"),
84  psetVsEta.getParameter<double>("tip"),
85  psetVsEta.getParameter<double>("lip"),
86  psetVsEta.getParameter<int>("minHit"),
87  psetVsEta.getParameter<bool>("signalOnly"),
88  psetVsEta.getParameter<bool>("chargedOnly"),
89  psetVsEta.getParameter<bool>("stableOnly"),
90  psetVsEta.getParameter<std::vector<int> >("pdgId"));
91 
92  useGsf = pset.getParameter<bool>("useGsf");
93  runStandalone = pset.getParameter<bool>("runStandalone");
94 
95  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
96 
97  labelTokenForDrCalculation = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("trackCollectionForDrCalculation"));
98 
99  if (!UseAssociators) {
100  associators.clear();
101  associators.push_back(assMapInput.label());
102  } else {
103  for (auto const& associatorName : associators) {
104  consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag(associatorName));
105  }
106  }
107 
108 }
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 111 of file MultiTrackValidator.cc.

References histoProducerAlgo_.

111 {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 160 of file MultiTrackValidator.cc.

References _simHitTpMapTag, assMapInput, 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(), plotBeamSpotDB::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, bookConverter::max, min(), TrackingParticle::momentum(), eostools::move(), 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, HLT_25ns14e33_v3_cff::trackCollection, UseAssociators, TrackingParticle::vertex(), w, and cms::Exception::what().

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

References ecalcalib_dqm_sourceclient-live_cfg::algo, MultiTrackValidatorBase::associators, MTVHistoProducerAlgo::bookRecoHistos(), MTVHistoProducerAlgo::bookRecoHistosForStandaloneRunning(), MTVHistoProducerAlgo::bookSimHistos(), DQMStore::IBooker::cd(), TrackerOfflineValidation_Dqm_cff::dirName, dirName_, histoProducerAlgo_, MTVHistoProducerAlgo::initialize(), edm::InputTag::instance(), edm::InputTag::label(), MultiTrackValidatorBase::label, edm::InputTag::process(), python.rootplot.root2matplotlib::replace(), runStandalone, and DQMStore::IBooker::setCurrentFolder().

114  {
115 
116  for (unsigned int ww=0;ww<associators.size();ww++){
117  for (unsigned int www=0;www<label.size();www++){
118  ibook.cd();
119  InputTag algo = label[www];
120  string dirName=dirName_;
121  if (algo.process()!="")
122  dirName+=algo.process()+"_";
123  if(algo.label()!="")
124  dirName+=algo.label()+"_";
125  if(algo.instance()!="")
126  dirName+=algo.instance()+"_";
127  if (dirName.find("Tracks")<dirName.length()){
128  dirName.replace(dirName.find("Tracks"),6,"");
129  }
130  string assoc= associators[ww];
131  if (assoc.find("Track")<assoc.length()){
132  assoc.replace(assoc.find("Track"),5,"");
133  }
134  dirName+=assoc;
135  std::replace(dirName.begin(), dirName.end(), ':', '_');
136 
137  ibook.setCurrentFolder(dirName.c_str());
138 
139  // vector of vector initialization
140  histoProducerAlgo_->initialize(); //TO BE FIXED. I'D LIKE TO AVOID THIS CALL
141 
142  string subDirName = dirName + "/simulation";
143  ibook.setCurrentFolder(subDirName.c_str());
144 
145  //Booking histograms concerning with simulated tracks
147 
148  ibook.cd();
149  ibook.setCurrentFolder(dirName.c_str());
150 
151  //Booking histograms concerning with reconstructed tracks
154 
155  }//end loop www
156  }// end loop ww
157 }
void cd(void)
Definition: DQMStore.cc:266
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
std::string const & label() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:46
std::vector< std::string > associators
std::string const & instance() const
Definition: InputTag.h:43
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 576 of file MultiTrackValidator.cc.

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

576  {
577  int w=0;
578  for (unsigned int ww=0;ww<associators.size();ww++){
579  for (unsigned int www=0;www<label.size();www++){
582  w++;
583  }
584  }
585  //if ( out.size() != 0 && dbe_ ) dbe_->save(out);
586 }
const double w
Definition: UKUtility.cc:23
std::vector< edm::InputTag > label
virtual void fillProfileHistosFromVectors(int counter)=0
virtual void finalHistoFits(int counter)=0
MTVHistoProducerAlgo * histoProducerAlgo_
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().