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")),
55 doSeedPlots_(pset.getUntrackedParameter<bool>(
"doSeedPlots"))
141 for(
const auto&
tag: pset.
getParameter< std::vector<edm::InputTag> >(
"label")) {
153 const auto minColl = -0.5;
154 const auto maxColl =
label.size()-0.5;
155 const auto nintColl =
label.size();
158 TH1 *
h = me->getTH1();
159 for(
size_t i=0;
i<
label.size(); ++
i) {
160 h->GetXaxis()->SetBinLabel(
i+1,
label[
i].
label().c_str());
176 for (
unsigned int ww=0;ww<
associators.size();ww++){
183 h_assoc_coll.push_back(binLabels( ibook.
book1D(
"num_assoc(simToReco)_coll",
"N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
184 h_simul_coll.push_back(binLabels( ibook.
book1D(
"num_simul_coll",
"N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
186 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) ));
187 h_simul_coll_allPt.push_back(binLabels( ibook.
book1D(
"num_simul_coll_allPt",
"N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
191 h_reco_coll.push_back(binLabels( ibook.
book1D(
"num_reco_coll",
"N of reco track vs track collection", nintColl, minColl, maxColl) ));
192 h_assoc2_coll.push_back(binLabels( ibook.
book1D(
"num_assoc(recoToSim)_coll",
"N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
193 h_looper_coll.push_back(binLabels( ibook.
book1D(
"num_duplicate_coll",
"N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
194 h_pileup_coll.push_back(binLabels( ibook.
book1D(
"num_pileup_coll",
"N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
198 for (
unsigned int www=0;www<
label.size();www++){
205 dirName+=algo.
label()+
"_";
208 if (dirName.find(
"Tracks")<dirName.length()){
209 dirName.replace(dirName.find(
"Tracks"),6,
"");
212 if (assoc.find(
"Track")<assoc.length()){
213 assoc.replace(assoc.find(
"Track"),5,
"");
241 using namespace reco;
243 LogDebug(
"TrackValidator") <<
"\n====================================================" <<
"\n"
244 <<
"Analyzing new event" <<
"\n"
245 <<
"====================================================\n" <<
"\n";
251 auto parametersDefinerTP = parametersDefinerTPHandle->clone();
265 parametersDefinerTP->initEvent(simHitsTPAssoc);
281 auto v_r2s = hvassociator->associateRecoToSim(hvertex, htv);
282 auto pvPtr = hvertex->refAt(0);
283 if(!(pvPtr->isFake() || pvPtr->ndof() < 0)) {
284 auto pvFound = v_r2s.find(pvPtr);
285 if(pvFound != v_r2s.end()) {
288 for(
const auto& vertexRefQuality: pvFound->val) {
295 if(simPVindex >= 0) {
297 thePVposition = &(pvPtr->position());
298 theSimPVPosition = &(pvFound->val[simPVindex].first->position());
312 event.getByToken(
bsSrc,recoBeamSpotHandle);
319 for (
unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
320 if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
321 puinfo=(*puinfoH)[puinfo_ite];
344 auto nlayers_tPCeff_ptrs = tpNumberOfLayersAlgo.
calculate(TPCollectionHeff, setup);
345 const auto& nLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nTrackerLayers>(nlayers_tPCeff_ptrs));
346 const auto& nPixelLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nPixelLayers>(nlayers_tPCeff_ptrs));
347 const auto& nStripMonoAndStereoLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nStripMonoAndStereoLayers>(nlayers_tPCeff_ptrs));
367 std::vector<size_t> selected_tPCeff;
368 std::vector<std::tuple<TrackingParticle::Vector, TrackingParticle::Point>> momVert_tPCeff;
369 selected_tPCeff.reserve(tPCeff.size());
370 momVert_tPCeff.reserve(tPCeff.size());
373 for(
size_t j=0;
j<tPCeff.size(); ++
j) {
379 histoProducerAlgo_->fill_generic_simTrack_histos(momentum, vertex, tpr->eventId().bunchCrossing());
381 if(tpr->eventId().bunchCrossing() == 0)
385 selected_tPCeff.push_back(
j);
386 momVert_tPCeff.emplace_back(momentum, vertex);
392 for(
auto const& tp: tPCeff) {
399 histoProducerAlgo_->fill_generic_simTrack_histos(tp.momentum(), tp.vertex(), tp.eventId().bunchCrossing());
401 if(tp.eventId().bunchCrossing() == 0)
405 selected_tPCeff.push_back(j);
409 momVert_tPCeff.emplace_back(momentum, vertex);
419 float dR_tPCeff[tPCeff.size()];
421 float etaL[tPCeff.size()], phiL[tPCeff.size()];
422 for(
size_t iTP: selected_tPCeff) {
424 auto const& tp2 = tPCeff[iTP];
425 auto &&
p = tp2.momentum();
426 etaL[iTP] = etaFromXYZ(
p.x(),
p.y(),
p.z());
427 phiL[iTP] = atan2f(
p.y(),
p.x());
430 for (
auto const & tp : tPCeff) {
433 auto &&
p = tp.momentum();
434 float eta = etaFromXYZ(
p.x(),
p.y(),
p.z());
435 float phi = atan2f(
p.y(),
p.x());
436 for(
size_t iTP: selected_tPCeff) {
438 if (
i==iTP) {
continue;}
440 if (dR_tmp<dR) dR=dR_tmp;
455 std::vector<const edm::ValueMap<reco::DeDxData> *> v_dEdx;
461 v_dEdx.push_back(dEdx1Handle.
product());
462 v_dEdx.push_back(dEdx2Handle.
product());
466 for (
unsigned int ww=0;ww<
associators.size();ww++){
467 for (
unsigned int www=0;www<
label.size();www++,
w++){
480 LogTrace(
"TrackValidator") <<
"Analyzing "
481 <<
label[www] <<
" with "
487 LogTrace(
"TrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
488 recSimCollL =
std::move(theAssociator->associateRecoToSim(trackCollection,
490 recSimCollP = &recSimCollL;
491 LogTrace(
"TrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
492 simRecCollL =
std::move(theAssociator->associateSimToReco(trackCollection,
494 simRecCollP = &simRecCollL;
499 simRecCollP = simtorecoCollectionH.
product();
505 simRecCollP = &simRecCollL;
509 recSimCollP = recotosimCollectionH.
product();
531 const int failed =
std::count(hseedToTrack->begin(), hseedToTrack->end(), -1);
542 LogTrace(
"TrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
549 for(
size_t i=0;
i<selected_tPCeff.size(); ++
i) {
550 size_t iTP = selected_tPCeff[
i];
554 auto const& momVert = momVert_tPCeff[
i];
562 double dR=dR_tPCeff[iTP];
573 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
574 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/
sqrt(momentum.perp2())
575 * momentum.z()/
sqrt(momentum.perp2());
577 if(theSimPVPosition) {
579 dxyPVSim = -(vertex.x()-theSimPVPosition->x())*
sin(momentum.phi()) + (vertex.y()-theSimPVPosition->y())*
cos(momentum.phi());
580 dzPVSim = vertex.z()-theSimPVPosition->z() - ( (vertex.x()-theSimPVPosition->x()) + (vertex.y()-theSimPVPosition->y()) )/
sqrt(momentum.perp2()) * momentum.z()/
sqrt(momentum.perp2());
586 momentumTP = std::get<TrackingParticle::Vector>(momVert);
587 vertexTP = std::get<TrackingParticle::Point>(momVert);
588 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
589 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2())
590 * momentumTP.z()/
sqrt(momentumTP.perp2());
613 if(simRecColl.
find(tpr) != simRecColl.
end()){
614 auto const & rt = simRecColl[tpr];
618 matchedTrackPointer = rt.begin()->first.get();
619 LogTrace(
"TrackValidator") <<
"TrackingParticle #" << st
620 <<
" with pt=" <<
sqrt(momentumTP.perp2())
621 <<
" associated with quality:" << rt.begin()->second <<
"\n";
625 <<
"TrackingParticle #" << st
626 <<
" with pt,eta,phi: "
627 <<
sqrt(momentumTP.perp2()) <<
" , "
628 << momentumTP.eta() <<
" , "
629 << momentumTP.phi() <<
" , "
630 <<
" NOT associated to any reco::Track" <<
"\n";
637 int nSimLayers = nLayers_tPCeff[tpr];
638 int nSimPixelLayers = nPixelLayers_tPCeff[tpr];
639 int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tpr];
640 histoProducerAlgo_->fill_recoAssociated_simTrack_histos(
w,tp,momentumTP,vertexTP,dxySim,dzSim,dxyPVSim,dzPVSim,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,matchedTrackPointer,puinfo.getPU_NumInteractions(),
dR, thePVposition);
642 if(matchedTrackPointer)
647 if (matchedTrackPointer) {
653 if (matchedTrackPointer) {
670 LogTrace(
"TrackValidator") <<
"\n# of reco::Tracks with "
671 <<
label[www].process()<<
":"
672 <<
label[www].label()<<
":"
673 <<
label[www].instance()
674 <<
": " << trackCollection->size() <<
"\n";
683 trackCollectionDr = trackCollectionForDrCalculation.product();
685 float dR_trk[trackCollection->size()];
687 float etaL[trackCollectionDr->
size()];
688 float phiL[trackCollectionDr->
size()];
689 for (
auto const & track2 : *trackCollectionDr) {
690 auto &&
p = track2.momentum();
691 etaL[
i] = etaFromXYZ(
p.x(),
p.y(),
p.z());
692 phiL[
i] = atan2f(
p.y(),
p.x());
696 auto const & track = (*trackCollection)[
i];
698 auto &&
p = track.momentum();
699 float eta = etaFromXYZ(
p.x(),
p.y(),
p.z());
700 float phi = atan2f(
p.y(),
p.x());
713 bool isSigSimMatched(
false);
714 bool isSimMatched(
false);
715 bool isChargeMatched(
true);
716 int numAssocRecoTracks = 0;
718 double sharedFraction = 0.;
720 auto tpFound = recSimColl.
find(track);
721 isSimMatched = tpFound != recSimColl.
end();
723 const auto& tp = tpFound->val;
724 nSimHits = tp[0].first->numberOfTrackerHits();
725 sharedFraction = tp[0].second;
726 if (tp[0].
first->charge() != track->
charge()) isChargeMatched =
false;
727 if(simRecColl.
find(tp[0].first) != simRecColl.
end()) numAssocRecoTracks = simRecColl[tp[0].
first].
size();
729 for (
unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
732 isSigSimMatched =
true;
737 LogTrace(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
738 <<
" associated with quality:" << tp.begin()->second <<
"\n";
740 LogTrace(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
741 <<
" NOT associated to any TrackingParticle" <<
"\n";
745 histoProducerAlgo_->fill_generic_recoTrack_histos(
w,*track,bs.position(), thePVposition, isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction,
dR);
750 if(numAssocRecoTracks>1) {
753 if(!isSigSimMatched) {
764 if (!isSimMatched)
continue;
788 int chargeTP = tpr->charge();
791 *track,bs.position());
802 LogTrace(
"TrackValidator") <<
"Total Simulated: " << st <<
"\n"
803 <<
"Total Associated (simToReco): " << ats <<
"\n"
804 <<
"Total Reconstructed: " << rT <<
"\n"
805 <<
"Total Associated (recoToSim): " << at <<
"\n"
806 <<
"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
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
math::XYZPoint Point
point in the space
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
std::vector< edm::EDGetTokenT< std::vector< int > > > seedToTrackTokens_
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_
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
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_