46 parametersDefinerIsCosmic_(parametersDefiner ==
"CosmicParametersDefinerForTP"),
47 calculateDrSingleCollection_(pset.getUntrackedParameter<bool>(
"calculateDrSingleCollection")),
48 doPlotsOnlyForTruePV_(pset.getUntrackedParameter<bool>(
"doPlotsOnlyForTruePV")),
49 doSummaryPlots_(pset.getUntrackedParameter<bool>(
"doSummaryPlots")),
50 doSimPlots_(pset.getUntrackedParameter<bool>(
"doSimPlots")),
51 doSimTrackPlots_(pset.getUntrackedParameter<bool>(
"doSimTrackPlots")),
52 doRecoTrackPlots_(pset.getUntrackedParameter<bool>(
"doRecoTrackPlots")),
53 dodEdxPlots_(pset.getUntrackedParameter<bool>(
"dodEdxPlots")),
54 doPVAssociationPlots_(pset.getUntrackedParameter<bool>(
"doPVAssociationPlots"))
146 const auto minColl = -0.5;
147 const auto maxColl =
label.size()-0.5;
148 const auto nintColl =
label.size();
151 TH1 *
h = me->getTH1();
152 for(
size_t i=0;
i<
label.size(); ++
i) {
153 h->GetXaxis()->SetBinLabel(
i+1,
label[
i].
label().c_str());
169 for (
unsigned int ww=0;ww<
associators.size();ww++){
176 h_assoc_coll.push_back(binLabels( ibook.
book1D(
"num_assoc(simToReco)_coll",
"N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
177 h_simul_coll.push_back(binLabels( ibook.
book1D(
"num_simul_coll",
"N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
179 h_assoc_coll_allPt.push_back(binLabels( ibook.
book1D(
"num_assoc(simToReco)_coll_allPt",
"N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
180 h_simul_coll_allPt.push_back(binLabels( ibook.
book1D(
"num_simul_coll_allPt",
"N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
184 h_reco_coll.push_back(binLabels( ibook.
book1D(
"num_reco_coll",
"N of reco track vs track collection", nintColl, minColl, maxColl) ));
185 h_assoc2_coll.push_back(binLabels( ibook.
book1D(
"num_assoc(recoToSim)_coll",
"N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
186 h_looper_coll.push_back(binLabels( ibook.
book1D(
"num_duplicate_coll",
"N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
187 h_pileup_coll.push_back(binLabels( ibook.
book1D(
"num_pileup_coll",
"N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
191 for (
unsigned int www=0;www<
label.size();www++){
198 dirName+=algo.
label()+
"_";
201 if (dirName.find(
"Tracks")<dirName.length()){
202 dirName.replace(dirName.find(
"Tracks"),6,
"");
205 if (assoc.find(
"Track")<assoc.length()){
206 assoc.replace(assoc.find(
"Track"),5,
"");
230 using namespace reco;
232 LogDebug(
"TrackValidator") <<
"\n====================================================" <<
"\n"
233 <<
"Analyzing new event" <<
"\n"
234 <<
"====================================================\n" <<
"\n";
240 auto parametersDefinerTP = parametersDefinerTPHandle->clone();
254 parametersDefinerTP->initEvent(simHitsTPAssoc);
270 auto v_r2s = hvassociator->associateRecoToSim(hvertex, htv);
271 auto pvPtr = hvertex->refAt(0);
272 if(!(pvPtr->isFake() || pvPtr->ndof() < 0)) {
273 auto pvFound = v_r2s.find(pvPtr);
274 if(pvFound != v_r2s.end()) {
277 for(
const auto& vertexRefQuality: pvFound->val) {
284 if(simPVindex >= 0) {
286 thePVposition = &(pvPtr->position());
287 theSimPVPosition = &(pvFound->val[simPVindex].first->position());
301 event.getByToken(
bsSrc,recoBeamSpotHandle);
308 for (
unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
309 if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
310 puinfo=(*puinfoH)[puinfo_ite];
333 auto nlayers_tPCeff_ptrs = tpNumberOfLayersAlgo.
calculate(TPCollectionHeff, setup);
334 const auto& nLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nTrackerLayers>(nlayers_tPCeff_ptrs));
335 const auto& nPixelLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nPixelLayers>(nlayers_tPCeff_ptrs));
336 const auto& nStripMonoAndStereoLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nStripMonoAndStereoLayers>(nlayers_tPCeff_ptrs));
356 std::vector<size_t> selected_tPCeff;
357 std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>> momVert_tPCeff;
358 selected_tPCeff.reserve(tPCeff.size());
359 momVert_tPCeff.reserve(tPCeff.size());
362 for(
size_t j=0;
j<tPCeff.size(); ++
j) {
368 histoProducerAlgo_->fill_generic_simTrack_histos(momentum, vertex, tpr->eventId().bunchCrossing());
370 if(tpr->eventId().bunchCrossing() == 0)
374 selected_tPCeff.push_back(
j);
375 momVert_tPCeff.emplace_back(momentum, vertex);
381 for(
auto const& tp: tPCeff) {
388 histoProducerAlgo_->fill_generic_simTrack_histos(tp.momentum(), tp.vertex(), tp.eventId().bunchCrossing());
390 if(tp.eventId().bunchCrossing() == 0)
394 selected_tPCeff.push_back(j);
398 momVert_tPCeff.emplace_back(momentum, vertex);
408 float dR_tPCeff[tPCeff.size()];
410 float etaL[tPCeff.size()], phiL[tPCeff.size()];
411 for(
size_t iTP: selected_tPCeff) {
413 auto const& tp2 = tPCeff[iTP];
414 auto &&
p = tp2.momentum();
415 etaL[iTP] = etaFromXYZ(
p.x(),
p.y(),
p.z());
416 phiL[iTP] = atan2f(
p.y(),
p.x());
419 for (
auto const & tp : tPCeff) {
422 auto &&
p = tp.momentum();
423 float eta = etaFromXYZ(
p.x(),
p.y(),
p.z());
424 float phi = atan2f(
p.y(),
p.x());
425 for(
size_t iTP: selected_tPCeff) {
427 if (
i==iTP) {
continue;}
429 if (dR_tmp<dR) dR=dR_tmp;
444 std::vector<const edm::ValueMap<reco::DeDxData> *> v_dEdx;
450 v_dEdx.push_back(dEdx1Handle.
product());
451 v_dEdx.push_back(dEdx2Handle.
product());
455 for (
unsigned int ww=0;ww<
associators.size();ww++){
456 for (
unsigned int www=0;www<
label.size();www++,
w++){
469 LogTrace(
"TrackValidator") <<
"Analyzing "
470 <<
label[www] <<
" with "
476 LogTrace(
"TrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
477 recSimCollL =
std::move(theAssociator->associateRecoToSim(trackCollection,
479 recSimCollP = &recSimCollL;
480 LogTrace(
"TrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
481 simRecCollL =
std::move(theAssociator->associateSimToReco(trackCollection,
483 simRecCollP = &simRecCollL;
488 simRecCollP = simtorecoCollectionH.
product();
494 simRecCollP = &simRecCollL;
498 recSimCollP = recotosimCollectionH.
product();
523 LogTrace(
"TrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
530 for(
size_t i=0;
i<selected_tPCeff.size(); ++
i) {
531 size_t iTP = selected_tPCeff[
i];
535 auto const& momVert = momVert_tPCeff[
i];
543 double dR=dR_tPCeff[iTP];
554 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
555 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/
sqrt(momentum.perp2())
556 * momentum.z()/
sqrt(momentum.perp2());
558 if(theSimPVPosition) {
560 dxyPVSim = -(vertex.x()-theSimPVPosition->x())*
sin(momentum.phi()) + (vertex.y()-theSimPVPosition->y())*
cos(momentum.phi());
561 dzPVSim = vertex.z()-theSimPVPosition->z() - ( (vertex.x()-theSimPVPosition->x()) + (vertex.y()-theSimPVPosition->y()) )/
sqrt(momentum.perp2()) * momentum.z()/
sqrt(momentum.perp2());
567 momentumTP = std::get<TrackingParticle::Vector>(momVert);
568 vertexTP = std::get<TrackingParticle::Point>(momVert);
569 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
570 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2())
571 * momentumTP.z()/
sqrt(momentumTP.perp2());
594 if(simRecColl.
find(tpr) != simRecColl.
end()){
595 auto const & rt = simRecColl[tpr];
599 matchedTrackPointer = rt.begin()->first.get();
600 LogTrace(
"TrackValidator") <<
"TrackingParticle #" << st
601 <<
" with pt=" <<
sqrt(momentumTP.perp2())
602 <<
" associated with quality:" << rt.begin()->second <<
"\n";
606 <<
"TrackingParticle #" << st
607 <<
" with pt,eta,phi: "
608 <<
sqrt(momentumTP.perp2()) <<
" , "
609 << momentumTP.eta() <<
" , "
610 << momentumTP.phi() <<
" , "
611 <<
" NOT associated to any reco::Track" <<
"\n";
618 int nSimLayers = nLayers_tPCeff[tpr];
619 int nSimPixelLayers = nPixelLayers_tPCeff[tpr];
620 int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tpr];
621 histoProducerAlgo_->fill_recoAssociated_simTrack_histos(
w,tp,momentumTP,vertexTP,dxySim,dzSim,dxyPVSim,dzPVSim,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,matchedTrackPointer,puinfo.getPU_NumInteractions(),
dR, thePVposition);
623 if(matchedTrackPointer)
628 if (matchedTrackPointer) {
634 if (matchedTrackPointer) {
651 LogTrace(
"TrackValidator") <<
"\n# of reco::Tracks with "
652 <<
label[www].process()<<
":"
653 <<
label[www].label()<<
":"
654 <<
label[www].instance()
655 <<
": " << trackCollection->size() <<
"\n";
664 trackCollectionDr = trackCollectionForDrCalculation.product();
666 float dR_trk[trackCollection->size()];
668 float etaL[trackCollectionDr->
size()];
669 float phiL[trackCollectionDr->
size()];
670 for (
auto const & track2 : *trackCollectionDr) {
671 auto &&
p = track2.momentum();
672 etaL[
i] = etaFromXYZ(
p.x(),
p.y(),
p.z());
673 phiL[
i] = atan2f(
p.y(),
p.x());
677 auto const & track = (*trackCollection)[
i];
679 auto &&
p = track.momentum();
680 float eta = etaFromXYZ(
p.x(),
p.y(),
p.z());
681 float phi = atan2f(
p.y(),
p.x());
694 bool isSigSimMatched(
false);
695 bool isSimMatched(
false);
696 bool isChargeMatched(
true);
697 int numAssocRecoTracks = 0;
699 double sharedFraction = 0.;
701 auto tpFound = recSimColl.
find(track);
702 isSimMatched = tpFound != recSimColl.
end();
704 const auto& tp = tpFound->val;
705 nSimHits = tp[0].first->numberOfTrackerHits();
706 sharedFraction = tp[0].second;
707 if (tp[0].
first->charge() != track->
charge()) isChargeMatched =
false;
708 if(simRecColl.
find(tp[0].first) != simRecColl.
end()) numAssocRecoTracks = simRecColl[tp[0].
first].
size();
710 for (
unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
713 isSigSimMatched =
true;
718 LogTrace(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
719 <<
" associated with quality:" << tp.begin()->second <<
"\n";
721 LogTrace(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
722 <<
" NOT associated to any TrackingParticle" <<
"\n";
726 histoProducerAlgo_->fill_generic_recoTrack_histos(
w,*track,bs.position(), thePVposition, isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction,
dR);
731 if(numAssocRecoTracks>1) {
734 if(!isSigSimMatched) {
745 if (!isSimMatched)
continue;
769 int chargeTP = tpr->charge();
772 *track,bs.position());
783 LogTrace(
"TrackValidator") <<
"Total Simulated: " << st <<
"\n"
784 <<
"Total Associated (simToReco): " << ats <<
"\n"
785 <<
"Total Reconstructed: " << rT <<
"\n"
786 <<
"Total Associated (recoToSim): " << at <<
"\n"
787 <<
"Total Fakes: " << rT-at <<
"\n";
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::InputTag > associators
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.
edm::EDGetTokenT< TrackingVertexCollection > label_tv
T_AssociationMap associationMapFilterValues(const T_AssociationMap &map, const T_RefVector &valueRefs)
TrackingParticleSelector dRtpSelector
TrackingParticleSelector dRtpSelectorNoPtCut
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
const bool doPlotsOnlyForTruePV_
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
std::vector< MonitorElement * > h_looper_coll
math::XYZTLorentzVectorD LorentzVector
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)
math::XYZPoint Point
point in the space
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.
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
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
const bool doSummaryPlots_
std::string parametersDefiner
std::vector< MonitorElement * > h_assoc_coll_allPt
void setCurrentFolder(const std::string &fullpath)
T const * product() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Method called to book the DQM histograms.
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
const bool doPVAssociationPlots_
EncodedEventId eventId() const
Signal source, crossing number.
Point vertex() const
Parent vertex position.
edm::EDGetTokenT< edm::View< reco::Vertex > > recoVertexToken_
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
const EncodedEventId & eventId() const
const bool calculateDrSingleCollection_
std::vector< MonitorElement * > h_simul_coll_allPt
std::vector< MonitorElement * > h_assoc2_coll
Monte Carlo truth information used for tracking validation.
int charge() const
track electric charge
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_
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_
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
virtual ~MultiTrackValidator()
Destructor.
const bool parametersDefinerIsCosmic_
const bool doSimTrackPlots_