47 parametersDefinerIsCosmic_(parametersDefiner ==
"CosmicParametersDefinerForTP"),
48 doSimPlots_(pset.getUntrackedParameter<bool>(
"doSimPlots")),
49 doSimTrackPlots_(pset.getUntrackedParameter<bool>(
"doSimTrackPlots")),
50 doRecoTrackPlots_(pset.getUntrackedParameter<bool>(
"doRecoTrackPlots")),
51 dodEdxPlots_(pset.getUntrackedParameter<bool>(
"dodEdxPlots"))
56 string histoProducerAlgoName = psetForHistoProducerAlgo.
getParameter<
string>(
"ComponentName");
124 const auto minColl = -0.5;
125 const auto maxColl =
label.size()-0.5;
126 const auto nintColl =
label.size();
129 TH1 *
h = me->getTH1();
130 for(
size_t i=0;
i<
label.size(); ++
i) {
131 h->GetXaxis()->SetBinLabel(
i+1,
label[
i].
label().c_str());
137 for (
unsigned int ww=0;ww<
associators.size();ww++){
141 h_reco_coll.push_back(binLabels( ibook.
book1D(
"num_reco_coll",
"N of reco track vs track collection", nintColl, minColl, maxColl) ));
142 h_assoc2_coll.push_back(binLabels( ibook.
book1D(
"num_assoc(recoToSim)_coll",
"N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
143 h_assoc_coll.push_back(binLabels( ibook.
book1D(
"num_assoc(simToReco)_coll",
"N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
144 h_simul_coll.push_back(binLabels( ibook.
book1D(
"num_simul_coll",
"N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
145 h_looper_coll.push_back(binLabels( ibook.
book1D(
"num_duplicate_coll",
"N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
146 h_pileup_coll.push_back(binLabels( ibook.
book1D(
"num_pileup_coll",
"N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
148 for (
unsigned int www=0;www<
label.size();www++){
155 dirName+=algo.
label()+
"_";
158 if (dirName.find(
"Tracks")<dirName.length()){
159 dirName.replace(dirName.find(
"Tracks"),6,
"");
162 if (assoc.find(
"Track")<assoc.length()){
163 assoc.replace(assoc.find(
"Track"),5,
"");
172 string subDirName = dirName +
"/simulation";
195 using namespace reco;
197 LogDebug(
"TrackValidator") <<
"\n====================================================" <<
"\n"
198 <<
"Analyzing new event" <<
"\n"
199 <<
"====================================================\n" <<
"\n";
205 auto parametersDefinerTP = parametersDefinerTPHandle->clone();
219 parametersDefinerTP->initEvent(simHitsTPAssoc);
225 event.getByToken(
bsSrc,recoBeamSpotHandle);
232 for (
unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
233 if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
234 puinfo=(*puinfoH)[puinfo_ite];
257 auto nlayers_tPCeff_ptrs = tpNumberOfLayersAlgo.
calculate(TPCollectionHeff, setup);
258 const auto& nLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nTrackerLayers>(nlayers_tPCeff_ptrs));
259 const auto& nPixelLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nPixelLayers>(nlayers_tPCeff_ptrs));
260 const auto& nStripMonoAndStereoLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nStripMonoAndStereoLayers>(nlayers_tPCeff_ptrs));
280 std::vector<size_t> selected_tPCeff;
281 std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>> momVert_tPCeff;
282 selected_tPCeff.reserve(tPCeff.size());
283 momVert_tPCeff.reserve(tPCeff.size());
285 for(
size_t j=0;
j<tPCeff.size(); ++
j) {
288 selected_tPCeff.push_back(
j);
291 momVert_tPCeff.emplace_back(momentum, vertex);
297 for(
auto const& tp: tPCeff) {
299 selected_tPCeff.push_back(j);
303 momVert_tPCeff.emplace_back(momentum, vertex);
310 float dR_tPCeff[tPCeff.size()];
312 float etaL[tPCeff.size()], phiL[tPCeff.size()];
313 for(
size_t iTP: selected_tPCeff) {
315 auto const& tp2 = tPCeff[iTP];
316 auto &&
p = tp2.momentum();
317 etaL[iTP] = etaFromXYZ(
p.x(),
p.y(),
p.z());
318 phiL[iTP] = atan2f(
p.y(),
p.x());
321 for (
auto const & tp : tPCeff) {
324 auto &&
p = tp.momentum();
325 float eta = etaFromXYZ(
p.x(),
p.y(),
p.z());
326 float phi = atan2f(
p.y(),
p.x());
327 for(
size_t iTP: selected_tPCeff) {
329 if (
i==iTP) {
continue;}
331 if (dR_tmp<dR) dR=dR_tmp;
344 std::vector<const edm::ValueMap<reco::DeDxData> *> v_dEdx;
350 v_dEdx.push_back(dEdx1Handle.
product());
351 v_dEdx.push_back(dEdx2Handle.
product());
355 for (
unsigned int ww=0;ww<
associators.size();ww++){
356 for (
unsigned int www=0;www<
label.size();www++){
369 LogTrace(
"TrackValidator") <<
"Analyzing "
370 <<
label[www] <<
" with "
376 LogTrace(
"TrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
377 recSimCollL = std::move(theAssociator->associateRecoToSim(trackCollection,
379 recSimCollP = &recSimCollL;
380 LogTrace(
"TrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
381 simRecCollL = std::move(theAssociator->associateSimToReco(trackCollection,
383 simRecCollP = &simRecCollL;
388 simRecCollP = simtorecoCollectionH.
product();
394 simRecCollP = &simRecCollL;
398 recSimCollP = recotosimCollectionH.
product();
423 LogTrace(
"TrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
430 for(
size_t i=0;
i<selected_tPCeff.size(); ++
i) {
431 size_t iTP = selected_tPCeff[
i];
435 auto const& momVert = momVert_tPCeff[
i];
441 double dR=dR_tPCeff[iTP];
452 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
453 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/
sqrt(momentum.perp2())
454 * momentum.z()/
sqrt(momentum.perp2());
459 momentumTP = std::get<TrackingParticle::Vector>(momVert);
460 vertexTP = std::get<TrackingParticle::Point>(momVert);
461 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
462 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2())
463 * momentumTP.z()/
sqrt(momentumTP.perp2());
488 if(simRecColl.
find(tpr) != simRecColl.
end()){
489 auto const & rt = simRecColl[tpr];
493 matchedTrackPointer = rt.begin()->first.get();
494 LogTrace(
"TrackValidator") <<
"TrackingParticle #" << st
495 <<
" with pt=" <<
sqrt(momentumTP.perp2())
496 <<
" associated with quality:" << rt.begin()->second <<
"\n";
500 <<
"TrackingParticle #" << st
501 <<
" with pt,eta,phi: "
502 <<
sqrt(momentumTP.perp2()) <<
" , "
503 << momentumTP.eta() <<
" , "
504 << momentumTP.phi() <<
" , "
505 <<
" NOT associated to any reco::Track" <<
"\n";
512 int nSimLayers = nLayers_tPCeff[tpr];
513 int nSimPixelLayers = nPixelLayers_tPCeff[tpr];
514 int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tpr];
515 histoProducerAlgo_->
fill_recoAssociated_simTrack_histos(
w,tp,momentumTP,vertexTP,dxySim,dzSim,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,matchedTrackPointer,puinfo.getPU_NumInteractions(),
dR);
518 if (matchedTrackPointer) {
538 LogTrace(
"TrackValidator") <<
"\n# of reco::Tracks with "
539 <<
label[www].process()<<
":"
540 <<
label[www].label()<<
":"
541 <<
label[www].instance()
542 <<
": " << trackCollection->size() <<
"\n";
549 float dR_trk[trackCollection->size()];
551 float etaL[trackCollectionForDrCalculation->size()];
552 float phiL[trackCollectionForDrCalculation->size()];
553 for (
auto const & track2 : *trackCollectionForDrCalculation) {
554 auto &&
p = track2.momentum();
555 etaL[
i] = etaFromXYZ(
p.x(),
p.y(),
p.z());
556 phiL[
i] = atan2f(
p.y(),
p.x());
560 auto const & track = (*trackCollection)[
i];
562 auto &&
p = track.momentum();
563 float eta = etaFromXYZ(
p.x(),
p.y(),
p.z());
564 float phi = atan2f(
p.y(),
p.x());
577 bool isSigSimMatched(
false);
578 bool isSimMatched(
false);
579 bool isChargeMatched(
true);
580 int numAssocRecoTracks = 0;
582 double sharedFraction = 0.;
584 auto tpFound = recSimColl.
find(track);
585 isSimMatched = tpFound != recSimColl.
end();
587 const auto& tp = tpFound->val;
588 nSimHits = tp[0].first->numberOfTrackerHits();
589 sharedFraction = tp[0].second;
590 if (tp[0].
first->charge() != track->
charge()) isChargeMatched =
false;
591 if(simRecColl.
find(tp[0].first) != simRecColl.
end()) numAssocRecoTracks = simRecColl[tp[0].
first].
size();
593 for (
unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
596 isSigSimMatched =
true;
601 LogTrace(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
602 <<
" associated with quality:" << tp.begin()->second <<
"\n";
604 LogTrace(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
605 <<
" NOT associated to any TrackingParticle" <<
"\n";
609 histoProducerAlgo_->
fill_generic_recoTrack_histos(
w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction,
dR);
613 if(numAssocRecoTracks>1) {
616 else if(!isSigSimMatched) {
626 if (!isSimMatched)
continue;
650 int chargeTP = tpr->charge();
653 *track,bs.position());
664 LogTrace(
"TrackValidator") <<
"Total Simulated: " << st <<
"\n"
665 <<
"Total Associated (simToReco): " << ats <<
"\n"
666 <<
"Total Reconstructed: " << rT <<
"\n"
667 <<
"Total Associated (recoToSim): " << at <<
"\n"
668 <<
"Total Fakes: " << rT-at <<
"\n";
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
std::vector< edm::InputTag > associators
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, int nSimLayers, int nSimPixelLayers, int nSimStripMonoAndStereoLayers, const reco::Track *track, int numVertices, double dR)=0
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
int event() const
get the contents of the subdetector field (should be protected?)
std::vector< MonitorElement * > h_reco_coll
bool ignoremissingtkcollection_
std::vector< edm::EDGetTokenT< reco::SimToRecoCollection > > associatormapStRs
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
CosmicTrackingParticleSelector cosmictpSelector
std::vector< TrackingParticle > TrackingParticleCollection
Vector momentum() const
spatial momentum vector
const_iterator end() const
last iterator over the map (read only)
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
std::vector< MonitorElement * > h_simul_coll
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
Sin< T >::type sin(const T &t)
const_iterator find(const key_type &k) const
find element with specified reference key
void analyze(const edm::Event &, const edm::EventSetup &) override
Method called once per event.
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
T_AssociationMap associationMapFilterValues(const T_AssociationMap &map, const T_RefVector &valueRefs)
TrackingParticleSelector dRtpSelector
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
std::vector< MonitorElement * > h_looper_coll
std::vector< MonitorElement * > h_pileup_coll
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
std::vector< MonitorElement * > h_assoc_coll
std::vector< edm::InputTag > label
std::vector< edm::EDGetTokenT< reco::RecoToSimCollection > > associatormapRtSs
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
int bunchCrossing() const
get the detector field from this detid
double pt() const
track transverse momentum
TrackingParticleSelector tpSelector
Cos< T >::type cos(const T &t)
MonitorElement * book1D(Args &&...args)
edm::EDGetTokenT< edm::View< reco::Track > > labelTokenForDrCalculation
double deltaR2(const T1 &t1, const T2 &t2)
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
virtual void bookRecoHistos(DQMStore::IBooker &ibook)=0
virtual void bookSimHistos(DQMStore::IBooker &ibook)=0
virtual void bookSimTrackHistos(DQMStore::IBooker &ibook)=0
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
MultiTrackValidator(const edm::ParameterSet &pset)
Constructor.
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
MTVHistoProducerAlgo * histoProducerAlgo_
std::string parametersDefiner
void setCurrentFolder(const std::string &fullpath)
virtual void fill_simAssociated_recoTrack_histos(int count, const reco::Track &track)=0
T const * product() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Method called to book the DQM histograms.
virtual void fill_trackBased_histos(int count, int assTracks, int numRecoTracks, int numSimTracks)=0
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
Parent vertex position.
std::tuple< std::unique_ptr< edm::ValueMap< unsigned int > >, std::unique_ptr< edm::ValueMap< unsigned int > >, std::unique_ptr< edm::ValueMap< unsigned int > > > calculate(const edm::Handle< TrackingParticleCollection > &tps, const edm::EventSetup &iSetup) const
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
std::vector< MonitorElement * > h_assoc2_coll
Monte Carlo truth information used for tracking validation.
virtual void fill_simTrackBased_histos(int count, int numSimTracks)=0
virtual void fill_dedx_recoTrack_histos(int count, const edm::RefToBase< reco::Track > &trackref, const std::vector< const edm::ValueMap< reco::DeDxData > * > &v_dEdx)=0
int charge() const
track electric charge
virtual void bookRecodEdxHistos(DQMStore::IBooker &ibook)=0
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
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
virtual void fill_generic_simTrack_histos(int counter, const TrackingParticle::Vector &, const TrackingParticle::Point &vertex, int bx)=0
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
const bool doRecoTrackPlots_
T get(const Candidate &c)
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
virtual ~MultiTrackValidator()
Destructor.
const bool parametersDefinerIsCosmic_
const bool doSimTrackPlots_